Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Rock, paper, scissors created by walkermatt -
# Rock, paper, scissors
def beats(thing1, thing2):
""" Determine who wins rock, paper, scissors
by passing each players choice """
if thing1 == thing2:
# Draw, both players chose the same thing
return None
# Determine which thing beats thing2
victors = {
"rock": "scissors",
"paper": "rock",
"scissors": "paper"
victor = victors[thing2]
return victor == thing1
# Tests
assert beats("rock", "paper") == True
assert beats("rock", "rock") == None
assert beats("scissors", "paper") == False
print "All assets pass!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.