I am new to programming & trying to create a best of 5 RPS game for my class but running into a few problems...when I call my score function that I created alternativley, it works but it then makes it so my while loop just keeps going, when I dont call the score function the while loops does stop at 3
def gamerps():
import random
YS= 0
CS= 0
rules = {("R", "S"), ("P", "R"), ("S", "P")}
msgs = {"R": "rock beats scissors", "P": "paper covers rock", "S":" scissors cut paper"}
while YS or CS <= 3:
YM = input("R/P/S?")
CM = random.choice(["R", "P", "S"])
if (YM, CM) in rules:
print ("You won! %s" % (msgs[YM]))
YS= YS+1
print (scorerps(YS, CS))
elif (CM, YM) in rules:
print ("You lost! %s" % (msgs[CM]))
CS= CS+1
print (scorerps(YS, CS))
elif YM == CM:
print ("Tie! Go again!")
else:
print ("ERROR, please choose R, P, or S for [R]ock [P]aper [S]cissors")
gamerps()
the score function works fine on its own and it does add the score throughout the rps game when applied, it just makes the game no longer stop at first to 3....
def scorerps(YS, CS):
if YS==CS:
print("scores are tied at", YS, "-", CS, "!")
elif YS >CS:
if YS==3:
print("You won ", YS, "-", CS,"!")
else:
print("You lead ", YS, "-", CS,"!")
elif CS>YS:
if CS==3:
print("Computer won ", CS, "-", YS,"!")
else:
print("computer leads ", CS, "-", YS,"!")
scorerps(1, 2)