Created
March 1, 2018 14:54
-
-
Save DivinityArcane/79d63cafca4167a7d660d0d3024a0a18 to your computer and use it in GitHub Desktop.
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 | |
print("Let's play some Rock, Paper, Scissors!") | |
options = ['rock', 'paper', 'scissors'] | |
trumps = {'rock': ['scissors'], 'paper': ['rock'], 'scissors': ['paper']} | |
wins = 0 | |
losses = 0 | |
running = True | |
while running: | |
option = input("What do you choose?: ") | |
if option not in options: | |
print('You must choose between ' + ', '.join(options)) | |
continue | |
cpuOption = options[random.randrange(len(options))] | |
print("You chose " + option + " while the computer chose " + cpuOption) | |
if option == cpuOption: | |
print("It's a tie! No one wins! Try again...") | |
print("\n") # move down a line for readability | |
continue | |
won = False | |
if cpuOption in trumps[option]: | |
won = True | |
if won: | |
print("You win! Congratulations! Let's try again...") | |
wins += 1 | |
else: | |
print("You lose! Better luck next time! Let's try again...") | |
losses += 1 | |
print("You've won %d time(s) and lost %d time(s)." % (wins, losses)) | |
print("\n") # move down a line for readability |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment