Running the below code in Python 3, I get the error: TypeError: 'str' object is not callable
Anyone know why? I thought this is exactly how to use the str() function!
import random
r = random.randint(0,50)
c = 0
g = 0
while g != r:
g = int(input())
c += 1
if g == r:
print("Correct. You had " + str(c) + " guesses")
elif g < r:
print("Too low.")
else:
print("Too high.")
Aucun commentaire:
Enregistrer un commentaire