Skip to content

Instantly share code, notes, and snippets.

@pdbartsch
Created February 7, 2019 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdbartsch/612a954de85da74289d9893f5ebd583a to your computer and use it in GitHub Desktop.
Save pdbartsch/612a954de85da74289d9893f5ebd583a to your computer and use it in GitHub Desktop.
def rps():
print('ROCK - PAPER - SCISSORS: \nRock beats scissors \nScissors beats paper \nPaper beats rock\n')
while True:
yn = input("Want to play? Yes or No: ").lower()
if yn[0] == 'y':
play()
else:
print('\nOK. Maybe later.')
break
def play():
one = input('Player One, choose either rock(R), paper(P), or scissors(S)? ').lower()
two = input('Player Two, choose either rock(R), paper(P), or scissors(S)? ').lower()
acceptible = ['r','p','s','rock','paper','scissors']
print('\nplayer one: ', one, '\nplayer two: ', two)
if one.lower() in acceptible and two.lower() in acceptible:
if one[0] == two[0]:
print( 'Tie')
elif one[0] == 'r':
if two[0] == 'p':
print('PLAYER TWO WINS!')
else:
print('PLAYER ONE WINS!')
elif one[0] == 'p':
if two[0] == 's':
print('PLAYER TWO WINS!')
else:
print('PLAYER ONE WINS!')
elif one[0] == 's':
if two[0] == 'r':
print('PLAYER TWO WINS!')
else:
print('PLAYER ONE WINS!')
else:
print("Something went wrong. Be sure to enter either rock, r, paper, p, scissors, or s.\n Try again:\n")
rps()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment