我有一个以TypeError结尾的函数,我不确定为什么:
#under 4 million
def fib(a, b):
a, b = 0, 1
while b <= 4000000:
a, b = b, (a+b)
print a
#always call it with "fib(0, 1)"
fiblist = [fib(0, 1)]
print fiblist
#now for the function that finds the sum of all even fib's
total = 0
for i in fiblist:
if i%2 == 0:
total = total + i
print total
这是错误消息:
Traceback (most recent call last):
File "C:\Python27\ProjectEuler\ProjectEuler2.py", line 19, in <module>
if i%2 == 0:
TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'
>>>
慕仙森
相关分类