这个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循环
答案 0 :(得分: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:
。
您的代码中还有其他错误。看看你是否可以通过测试找到它们。
答案 1 :(得分:0)