Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def main(userValue, compValue):
- userInput = False
- while not userInput:
- try:
- userValue = int(input("1. Rock, 2. Paper, or 3. Scissors? "))
- compValue = random.randint(1, 3)
- except ValueError:
- main(userValue, compValue)
- if userValue == compValue:
- print("Computer chose the same hand as you!")
- print("It's a tie!")
- elif userValue == 1 and compValue == 2:
- print("Computer chose paper.")
- print("You lose!")
- elif userValue == 1 and compValue == 3:
- print("Computer chose scissors.")
- print("You win!")
- elif userValue == 2 and compValue == 1:
- print("Computer chose rock.")
- print("You win!")
- elif userValue == 2 and compValue == 3:
- print("Computer chose scissors.")
- print("You lose!")
- elif userValue == 3 and compValue == 2:
- print("Computer chose paper.")
- print("You win!")
- elif userValue == 3 and compValue == 1:
- print("Computer chose rock.")
- print("You lose!")
- main(compValue, userValue)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement