cis_projects/ps1_3_joseph_green.py

54 lines
1.3 KiB
Python
Raw Permalink Normal View History

2017-02-11 01:21:04 -07:00
# Two player Rock Paper Scissors game
# Congradulate winner
# Ask if players wish to play again
players = ["",""]
quit = False
playersQuit = "y"
winner = "player "
tie = None
while quit == False:
i = 0
tie = None
winner = "player "
while i <=1: #Is there no for (i=0; i<2; i++) equiv in python?
print ("\n" * 100)
players[i] = input("Player " + str(i + 1) + ", enter (R)ock, (P)aper, or (S)cissors:" )
players[i] = players[i].lower()
if players[i] == "r" or players[i] == "p" or players[i] == "s":
i += 1
## else, repeat question
if players[0] == players[1]:
tie = True
print("We have a tie!!!")
elif players[0] == "r" and players[1] == "p":
winner += "2"
elif players[0] == "r" and players[1] == "s":
winner += "1"
elif players[0] == "s" and players[1] == "p":
winner += "1"
elif players[0] == "s" and players[1] == "r":
winner += "2"
elif players[0] == "p" and players[1] == "s":
winner += "2"
elif players[0] == "p" and players[1] == "r":
winner += "1"
if tie != True:
print("Congrats", winner, "You've won!")
playersQuit = input("Would you like to play again? (y/n): ")
if playersQuit.lower() == "n":
quit = True