Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import string
- lower = str.lower
- r = ["rock" , "scissors", "paper"]
- p = ["paper", "rock", "scissors"]
- s = ["scissors", "paper", "rock"]
- '''
- The order of the elements of this list is not random.
- The first element is the objct itself
- The second elements contains the object that the element can be beaten
- by the object.
- The last element contains the object that can beat the object
- '''
- objects = [r,p,s]
- print("ROCK, PAPER, SCISSORS! \nENTER 'Q' TO EXIT")
- q = None
- while q == None:
- compChoice = random.choice(objects)
- user = lower(input("\nCHOOSE YOUR OBJECT (ROCK/PAPER/SCISSORS):"))
- if user == compChoice[1]:
- print("You chose",user,". Computer chose",compChoice[0],". YOU LOOSE!")
- elif user == compChoice[2]:
- print("You chose",user,". Computer chose",compChoice[0],". YOU WIN!")
- elif user == compChoice[0]:
- print("You chose",user,". Computer chose",compChoice[0],". ITS A DRAW!")
- elif user == 'q':
- q = "EXIT"
- else:
- print("THAT'S NOT A VALID OPTION. PLEASE CHECK THE SPELLING.")
Add Comment
Please, Sign In to add comment