Guest User

Untitled

a guest
Nov 21st, 2018
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. import random
  2.  
  3. score1 = 0
  4. score2 = 0
  5.  
  6. def main():
  7. while True:
  8.  
  9. player = input('What do you choose to play (R, P, S)? ')
  10. computer = random.choice(["R", "P", "S"])
  11. print("You chose", (player), "and the computer chose", (computer))
  12.  
  13. if computer == player:
  14. print("It's a tie")
  15. print("Score: You =", score1, "Computer =", score2)
  16.  
  17. if computer == "R" and player == "S":
  18. print("Computer wins")
  19. print("Score: You =", score1, "Computer =", score2 + 1)
  20.  
  21. if computer == "P" and player == "R":
  22. print("Computer wins")
  23. print("Score: You =", score1, "Computer =", score2 + 1)
  24.  
  25. if computer == "S" and player == "P":
  26. print("Computer wins")
  27. print("Score: You =", score1, "Computer =", score2 + 1)
  28.  
  29. if computer == "S" and player == "R":
  30. print("You won")
  31. print("Score: You =", score1 + 1, "Computer =", score2)
  32.  
  33. if computer == "R" and player == "P":
  34. print("You won")
  35. print("Score: You =", score1 + 1, "Computer =", score2)
  36.  
  37. if computer == "P" and player == "S":
  38. print("You won")
  39. print("Score: You =", score1 + 1, "Computer =", score2)
  40.  
  41. play_again = input("Would you like to play again? Y/N ")
  42.  
  43. if play_again == "Y":
  44. main()
  45. if play_again == "y":
  46. main()
  47. if play_again == "Yes":
  48. main()
  49. if play_again == "yes":
  50. main()
  51. else:
  52. print("You scored", score1, "and the computer scored", score2)
  53. exit()
  54.  
  55. main()
Advertisement
Add Comment
Please, Sign In to add comment