2013-07-20 12 views
8

は、私はそれが...終わったが、それは私にいくつかの理由でエラーが発生しますないです---ハングマンを再生するプログラムを書いたはTypeError:「int型のオブジェクトが呼び出すことはできません,,, 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

の可能性の重複:([例外TypeError:「int型のオブジェクトが呼び出すことはできません] http://stackoverflow.com/questions/9767391/typeerror-int-objectそれはwhileが既に何をするかです-is-not-callable) –

答えて

20

あなたがローカル名lenに割り当てられた:

len=len(word) 

lenは、整数と影の内蔵Iでありますn機能。あなたが代わりにそこ異なるの名前を使用したい:

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

その他のヒント:

  • 代わりFalseへの平等のためのテストの使用not

    while not n: 
    
  • 同上テストのために== True;

    while y: 
    
関連する問題