I'm following along with python official tutorial.
I've created a fibonacci function fib()
as shown on the tutorial,
The output from the function given argument 1
was(to my surprise),
infinite trails of 0
.
>>> def fib(n):
... a, b = 0, 1
... while a < n:
... print a,
... a, b = b, a + b
...
>>> fib(0)
>>> fib(1)
0 0 0 0 0 0 0 0 0 0 (...repeats infinitely, had to break out with ^+Z ...)
I've tried to reproduce the issue, but couldn't succeed.
>>> def fib(n):
... a, b = 0, 1
... while a < n:
... print a,
... a, b = b, a + b
...
>>> fib(0)
>>> fib(1)
0
>>> fib(1)
0
Is this a known issue or perhaps some temporary glitch in the interpreter?