def fib(n): a, b = 0, 1 for _ in range(n): yield a a, b = b, a + b print(list(fib(10)))
Standard input is empty
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!