Advertisement
Talithacelin

Simple Rock paper scissors

Dec 15th, 2022
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | None | 0 0
  1. import random
  2. import time
  3.  
  4. print("ROCK PAPER SCISSORS")
  5. print(20*'-')
  6. rps = ['Rock = R' , 'Paper = P' , 'Scissors = S']
  7. for u in rps:
  8.     print(u)
  9.  
  10. while True :
  11.     try:
  12.         spr = ['R' ,'P' ,'S']
  13.         comp = random.choice(spr)
  14.         user = input("CHOOSE (R/P/S) : ")
  15.  
  16.         time.sleep(0.5)
  17.  
  18.         if user not in spr:
  19.             raise ValueError
  20.  
  21.         elif comp == 'R'and user == 'S':
  22.             print("Computer choose Rock. You Lose!")
  23.  
  24.         elif comp == 'S'and user == 'R':
  25.             print("Computer choose Scissors. You Win!")
  26.  
  27.         elif comp == 'P'and user == 'S':
  28.             print("Computer choose Paper. You Win!")
  29.  
  30.         elif comp == 'S'and user == 'P':
  31.             print("Computer choose Scissors. You Lose!")
  32.  
  33.         elif comp == 'R'and user == 'P':
  34.             print("Computer choose Rock. You Win!")
  35.  
  36.         elif comp == user:
  37.             print("Same as computer lol. Its a tie.")
  38.  
  39.         else:
  40.             print("Computer choose Paper. You Lose!")
  41.  
  42.     except ValueError:
  43.         print("NOT VALID ANSWER. Please reenter.")
  44.    
  45.  
  46.     again = input("Again?? ")
  47.     if again == "y" or again =="yes":
  48.         print()
  49.         continue
  50.  
  51.     else:
  52.         print("BYE")
  53.         break
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement