Skip to content

Instantly share code, notes, and snippets.

@jleeothon
Last active August 29, 2015 14:06
Show Gist options
  • Save jleeothon/c901e388f19d33c53a1c to your computer and use it in GitHub Desktop.
Save jleeothon/c901e388f19d33c53a1c to your computer and use it in GitHub Desktop.
Rock, paper, scissor
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()
@jleeothon
Copy link
Author

Maybe random.seed() should be put under "if main".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment