I'm trying to keep a count of the amount of times a random number is generated and stop it after a certain number has been hit. I'm new to python there's probably a simple fix that I can't see.
p = 0
def gameplay():
i = random.randint(1,2)
if i <= 1:
print(1)
p = p + 1
gameplay();
else:
print(2)
p = p + 1
gameplay();
if p <= 10:
gameplay();
I keep getting the error: "local variable 'p' referenced before assignment"