2013-10-19 106 views
-4

這個python程序是用來從用戶獲取2個數字的,其中一個是乘法表,它是用來增加的,另一個是數字停在。這也是迄今爲止該程序:TypeError:'builtin_function_or_method'對象是不可以訂閱的 - python

count = 0 

UI = 0 

UserInput = 10 

print ("Please type a number and press enter, this will be the multiplication table your sequence will go up in, then type another number and press enter, this will be the number the sequence will stop at.") 

UI = int(input("")) 

UserInput = int(input("")) 

print = ("The program will now display all the numbers between your two numbers") 

while all [count <= UserInput]: 

     count = count*UI 

     print (count) 

但它口口聲聲說:

Traceback (most recent call last): 
    File "C:/Users/Shahriyar/Documents/DiffProg.py", line 11, in <module> 
    while all [count <= UserInput]: 
TypeError: 'builtin_function_or_method' object is not subscriptable 

如何解決呢?請不要建議我使用一個for循環,因爲這是學校,我們註定要使用while循環

+2

格式代碼正確 –

+4

',而所有[計數<= UserInput]:'是無效的。 – iMom0

+1

while all [count <= UserInput] - 您正在發明新的語法... next in line。 –

回答

1

「它口口聲聲說」:

Traceback (most recent call last): 
    File "C:/Users/Shahriyar/Documents/DiffProg.py", line 11, in <module> 
    while all [count <= UserInput]: 
TypeError: 'builtin_function_or_method' object is not subscriptable 

,因爲該行代碼就再現,while all [count <= UserInput]:在語法上不是有效的。這不是python中的事情。您可能想要while count <= UserInput:

你的代碼還有其他錯誤。看看你是否可以使用測試找到他們。