TypeError:'int'对象不可调用,,, len()

Gil*_*man 13 python int python-2.7

我写了一个玩刽子手的程序---它还没有完成,但由于某些原因它给了我一个错误...

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"
Run Code Online (Sandbox Code Playgroud)

错误:

    leenghthp=len(p)
TypeError: 'int' object is not callable
Run Code Online (Sandbox Code Playgroud)

Mar*_*ers 32

您已分配到本地名称len:

len=len(word)
Run Code Online (Sandbox Code Playgroud)

现在len是一个整数并隐藏内置函数.你想在那里使用不同的名称:

length = len(word)
# other code
print "_ " * length
Run Code Online (Sandbox Code Playgroud)

其他提示: