Advertisement
Guest User

Rock/Paper/Scissors

a guest
Feb 28th, 2020
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. from random import randint
  2. #input
  3. print("Step right up for a game of Rock, Paper, Scissors!")
  4. choice = input("What's yer poison? [Rock/Paper/Scissors]: ").lower()
  5. ai_choice = randint(1,3)
  6. #pc choice alteration
  7. if ai_choice == 1:
  8.     ai_choice = "rock"
  9. elif ai_choice == 2:
  10.     ai_choice = "paper"
  11. elif ai_choice == 3:
  12.     ai_choice = "scissors"
  13. #error check
  14. if choice != "rock" and choice != "paper" and choice != "scissors":
  15.     print(f"{choice} is not a valid option. Get outta here!")
  16.     quit()
  17. #calculate winner
  18. print(f"Player: {choice} . . . PC: {ai_choice}")
  19. if choice == ai_choice:
  20.     print("It's a draw! Dagnabbit.")
  21. elif choice == 1 and ai_choice == 2:
  22.     print("No dice! You lose.")
  23. elif choice == 1 and ai_choice == 3:
  24.     print("You win this round, pardner!")
  25. elif choice == 2 and ai_choice == 1:
  26.     print("You win this round, pardner!")
  27. elif choice == 2 and ai_choice == 3:
  28.     print("No dice! You lose.")
  29. elif choice == 3 and ai_choice == 1:
  30.     print("No dice! You lose.")
  31. else:
  32.     print("You win this round, pardner!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement