()
| 1 | def fib(): |
| 2 | a, b = 0, 1 |
| 3 | while True: # First iteration: |
| 4 | yield a # yield 0 to start with and then |
| 5 | a, b = b, a + b # a will now be 1, and b will also be 1, (0 + 1) |
| 6 | |
| 7 | for index, fibonacci_number in zip(range(100), fib()): |
| 8 | print('{i:3}: {f:3}'.format(i=index, f=fibonacci_number)) |