2013-07-20 78 views
8

我写了一个程序播放刽子手---这还不算完,但它给了我一些原因的错误...类型错误:“诠释”对象不是可调用,,, LEN()

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" 

错误:

leenghthp=len(p) 
TypeError: 'int' object is not callable 
+0

的可能重复[类型错误: '诠释' 对象不是可调用(http://stackoverflow.com/questions/9767391/typeerror-int-object -is - 不赎回) –

回答

20

您分配给本地名len

len=len(word) 

现在len是一个整数和阴影内建我n功能。你想用一个不同名有代替:

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

其他提示:

  • 使用not,而不是测试平等False

    while not n: 
    
  • 同上,用于测试为== True;这就是while已经确实

    while y: 
    
相关问题