Last active
August 29, 2015 14:06
-
-
Save jleeothon/c901e388f19d33c53a1c to your computer and use it in GitHub Desktop.
Rock, paper, scissor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
random.seed() | |
defeat = {'rock': 'scissor', 'paper': 'rock', 'scissor': 'paper'} | |
def ask_user(): | |
while True: | |
user_choice = input('Say: ') | |
if user_choice in defeat: | |
return user_choice | |
def play(): | |
my_choice = random.choice(defeat) | |
user_choice = ask_user() | |
if user_choice == my_choice: | |
print('DRAW!') | |
elif user_choice == defeat[my_choice]: | |
print('LOSER!') | |
else: | |
print('I HATE YOU.') | |
print('I had chosen %s.' % my_choice) | |
if __name__ == '__main__': | |
play() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe
random.seed()
should be put under "if main".