Guest User

Untitled

a guest
Apr 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import random
  2. import string
  3. lower = str.lower
  4.  
  5. r = ["rock" , "scissors", "paper"]
  6. p = ["paper", "rock", "scissors"]
  7. s = ["scissors", "paper", "rock"]
  8. '''
  9. The order of the elements of this list is not random.
  10. The first element is the objct itself
  11. The second elements contains the object that the element can be beaten
  12. by the object.
  13. The last element contains the object that can beat the object
  14. '''
  15. objects = [r,p,s]
  16.  
  17. print("ROCK, PAPER, SCISSORS! \nENTER 'Q' TO EXIT")
  18. q = None
  19. while q == None:
  20. compChoice = random.choice(objects)
  21. user = lower(input("\nCHOOSE YOUR OBJECT (ROCK/PAPER/SCISSORS):"))
  22. if user == compChoice[1]:
  23. print("You chose",user,". Computer chose",compChoice[0],". YOU LOOSE!")
  24. elif user == compChoice[2]:
  25. print("You chose",user,". Computer chose",compChoice[0],". YOU WIN!")
  26. elif user == compChoice[0]:
  27. print("You chose",user,". Computer chose",compChoice[0],". ITS A DRAW!")
  28. elif user == 'q':
  29. q = "EXIT"
  30. else:
  31. print("THAT'S NOT A VALID OPTION. PLEASE CHECK THE SPELLING.")
Add Comment
Please, Sign In to add comment