Making a RPS game for a school assignment
import random
#player score
p1 = 0
p2 = 0
#add score
def AddScore(a,c):
print(a + " +1")
if c == "hum":
p1+=1
else:
p2+=1
#gets player choices
while p1 < 3 or p2 < 3:
print("Rock, Paper, Scissors, Shoot!")
a = int(input("Rock, Paper or Scissors? (1, 2, 3):"))
b = random.randint(1,3)
if a == b:
print("Draw!")
elif a > b and a != 1:
AddScore("Human", "hum")
elif a == 1 and b == 3:
AddScore("Human", "hum")
elif b > a and b != 1:
AddScore("Computer", "comp")
elif a == b and a == 3:
AddScore("Computer", "comp")
print(p1)
print(p2)
returns error on lines 9 and 21:
UnboundLocalError: local variable 'p1' referenced before assignment