2013-10-19 70 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:

你的代码还有其他错误。看看你是否可以使用测试找到他们。