我写了一个小模块 -
def fib(n): #write Fibonacci series up to n
a, b = 0, 1
while b < n:
print b,
a, b = b, b+a
def fib2(n): #return Fibonacci series up to n
result = []
a, b = 0, 1
while b < n:
result.append(b)
a, b = b, a+b
return result
然后我将其导入另一个脚本fibonacci.py
from fibo import fib
num = raw_input('Enter the value of N :: ')
print fib(num)
当我运行fibonacci.py时,提示要求我输入N的值。当我这样做并按回车时,它开始打印数字,卡在无限循环中。数字的打印继续并继续......
我可能做错了什么?