Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import random
  2.  
  3. def main(userValue, compValue):
  4. userInput = False
  5. while not userInput:
  6. try:
  7. userValue = int(input("1. Rock, 2. Paper, or 3. Scissors? "))
  8. compValue = random.randint(1, 3)
  9. except ValueError:
  10. main(userValue, compValue)
  11. if userValue == compValue:
  12. print("Computer chose the same hand as you!")
  13. print("It's a tie!")
  14. elif userValue == 1 and compValue == 2:
  15. print("Computer chose paper.")
  16. print("You lose!")
  17. elif userValue == 1 and compValue == 3:
  18. print("Computer chose scissors.")
  19. print("You win!")
  20. elif userValue == 2 and compValue == 1:
  21. print("Computer chose rock.")
  22. print("You win!")
  23. elif userValue == 2 and compValue == 3:
  24. print("Computer chose scissors.")
  25. print("You lose!")
  26. elif userValue == 3 and compValue == 2:
  27. print("Computer chose paper.")
  28. print("You win!")
  29. elif userValue == 3 and compValue == 1:
  30. print("Computer chose rock.")
  31. print("You lose!")
  32.  
  33. main(compValue, userValue)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement