jeudi 6 décembre 2018

Why do I keep getting "TypeError: 'str' object is not callable", when simply trying to concatenate an integer with a string using str()? [on hold]

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