This program is a rock paper scissors simulation. There are two players and each enters r, p or s (lower or upper case). The program then lets the players know who won based on the normal rps rules. There are 5 rounds and it prints the results of each individual game and a running total of games won.
My problem is that it is only evaluating player two as the winner no matter what. I realize a lot of this could be written in a much better way, but I'm just starting out and don't want to change the code too much. I just want it to work. Thanks a lot!
print("Hello! We're gonna play a few games of Rock, Paper Scissors.")
def rpsGame():
def rps():
player1=input('R, P or S?')
player2=input('R, P or S?')
if player1==player2:
return 0
if (player1==('R'or'r')and player2==('S'or's'))or(player1==('S'or's')and player2==('P'or'p'))or(player1==('P'or'p')and player2==('R'or'r')):
return 1
if (player2==('R'or'r')and player1==('S'or's'))or(player2==('S'or's')and player1==('P'or'p'))or(player2==('P'or'p')and player1==('R'or'r')):
return 2
result=rps()
return result
numWinsP1=0
numWinsP2=0
for i in range(5):
result=rpsGame()
if result==0:
print('Nobody wins')
elif result==1:
numWinsP1=numWinsP1+1
print('Player 1 wins.')
else:
numWinsP2=numWinsP2+1
print('Player 2 wins.')
print("Scores after this play: Player 1:",numWinsP1," Player 2:",numWinsP2)
print('Thanks for playing!')