Rock Paper Scissors Game Python || Python
In this we are going to see a basic program to rock paper scissors game in Python Programming Language.



import random
elements = ['Rock', 'Paper', 'Scissors']
score = 0
comp_score = 0

print("Welcome to Rock Paper Scissors Game")
print("You can choose between Rock, Paper and Scissors")
print("The One With 3 Wins Will Be The Winner")
print("----------------xxxxxxxxxxxxx-----------------------")
def player():
    player_choice = input("Enter your choice: ")
    if player_choice in elements:
        return player_choice
    else:
        print("Invalid Choice")
        player()

while True:
    x = player()
    print("Player Choice: ",x)
    y = random.choice(elements)
    print("Computer Choice: ",y)
    if x == y:
        print("Tie")
    elif x == "Rock" and y == "Scissors":
        print("Player Wins")
        score += 1
    elif x == "Rock" and y == "Paper":
        print("Computer Wins")
        comp_score += 1
    elif x == "Paper" and y == "Rock":
        print("Player Wins")
        score += 1
    elif x == "Paper" and y == "Scissors":
        print("Computer Wins")
        comp_score += 1
    elif x == "Scissors" and y == "Rock":
        print("Computer Wins")
        comp_score += 1
    elif x == "Scissors" and y == "Paper":
        print("Player Wins")
        score += 1
    if score == 3 and comp_score < 3:
        print("----------------xxxxxxxxxxxxx-----------------------")
        print("Player Wins")
        break
    elif comp_score == 3 and score < 3:
        print("----------------xxxxxxxxxxxxx-----------------------")
        print("Computer Wins")
        break

print("Player Score: ",score)
print("Computer Score: ",comp_score)

# Coded By DHIRAJ SHELKE


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post