TypeError: 'int' object is not callable,,, len()

int, python, python-2.7

Solution

You assigned to a local name `len`:

len=len(word)

Now `len` is an integer and shadows the built-in function. You want to use a different name there instead:

length = len(word)
# other code
print "_ " * length

Other tips:

Use `not` instead of testing for equality to `False`:

while not n:

Ditto for testing for `== True`; that is what `while` already does:

while y:

Problem

I wrote a program to play hangman---it's not finished but it gives me an error for some reason... ``` import turtle n=False y=True list=() print ("welcome to the hangman! you word is?") word=raw_input() len=len(word) for x in range(70): print print "_ "*len while n==False: while y==True: print "insert a letter:" p=raw_input() leenghthp=len(p) if leengthp!=1: print "you didnt give me a letter!!!" else: y=False for x in range(len): #if wo print "done" ``` error: ``` leenghthp=len(p) TypeError: 'int' object is not callable ```

Original source

Related problems