2013-07-20 20 views
8

Ben ... bitmiş ama bana nedense bir hata veriyor değil --- asmaca oynamak için bir program yazdımTypeError: 'int' nesne çağrılabilir değil ,,, 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" 

hata: bir yerel isim len atanan

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

olası yinelenen: ([TypeError: 'int' nesne çağrılabilir değil] http://stackoverflow.com/questions/9767391/typeerror-int-object o while zaten yaptığı iştir -is-çağrılabilir) –

cevap

20

: Artık

len=len(word) 

len bir tam sayıdır ve i yerleşik gölgeler n işlevi. Bunun yerine orada bir farklı adı kullanmak istiyorum:

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

Diğer ipuçları:

  • Kullanım not yerine eşitlik için test False için:

    while not n: 
    
  • Ditto testi için == True için;

    while y: 
    
İlgili konular