Rock-Paper-Scissor

Try out the Rock-Paper-Scissor with your computer and learn while you play!

Welcome to the code! Remember the old game we all used to play during our classes and in the playgrounds. Now, you can learn to code while you play the game.

In this code, you will be able to choose rock or paper or scissor while your computer chooses its decision in the background and you will be competing against your computer to win.

Note: Loved the post? You too can publish your article on “Python for fun” which will be loved by millions. Contribute an article!

							
							
					import random

options = ["rock", "paper", "scissor"]

computer = random.choice(options)

def player_input():
    player = input("Choose one among 'Rock', 'Paper, 'Scissor': ")
    player = player.lower()
    return player
    

player = player_input()
if computer == player:
    print("Wow! That's a tie.")
    
elif computer == "rock":
    if player == "paper":
        print("You won!")
    else:
        print("You lost!")
elif computer == "paper":
    if player == "scissor":
        print("You won!")
    else:
        print("You lose!")
elif computer == "scissor":
    if player == "rock":
        print("You won!")
    else:
        print("You lose!")
else:
    print("There's some issue.. Please enter your choice again...")
    player_input()

print("Computer chose", computer)				
			
0 0 votes
Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments