#import random function from random import randint options = ["Rock", "Paper", "Scissors"] randIndex = randint(0,2) computer_Choice = options[randIndex] player_Choice = True while player_Choice == True: player_Choice = input("What's your move? Rock, Paper, or Scissors?") if player_Choice == computer_Choice: print("Tie!!") elif player_Choice == "Rock": if computer_Choice == "Paper": print("You lose! Computer covered your ", player_Choice, "with ", computer_Choice) else: #computer_Choice == "Scissors" print("You win!! Your rock crushed the computer's scissors.") elif player_Choice == "Paper": if computer_Choice == "Rock": print("Computer chose Rock.") print("You win!!") else: #computer_Choice == "Scissors" print("Computer chose Scissors.") print("You lose!!") elif player_Choice == "Scissors": if computer_Choice == "Paper": print("You win!! Your scissors cut the computer's paper") else: #computer_Choice == "Rock" print("You lose!! The computer crushed your scissors with a rock.") else: #if player typed an invalid choice print("Invalid choice.") print("Play again?") again = input("Y for yes, N for no") if again == "Y": player_Choice = True computer_Choice = options[randint(0,2)]
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question