next_number = []
for i in range(len(fib)):
while next_number < [10]:
next_number = fib[i] + fib[i + 1]
fib.append(next_number)
print(next_number)
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
euler_fibbonacci([0, 1])
File "C:\Python33\euler_fibbonacci.py", line 17, in euler_fibbonacci
while next_number < limit:
TypeError: unorderable types: int() < list()
为什么他给我这个错误,因为next_number是list而[10]也是一个列表。
答案 0 :(得分:2)
首先通过while
循环执行此操作:
next_number = fib[i] + fib[i + 1]
fib[i] + fib[i + 1]
是int
。下一个过程首先检查int
是否小于[10],这会引发TypeError
。