Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Operations on Unbound iterator

from fibonacci import Fibonacci

fib = Fibonacci()

#odd = [x for x in fib if x % 2 == 1]
odd = filter(lambda x: x % 2 == 1, fib)

print("Let's see")

for v in odd:
    print(v)
    if v > 10:
        break

Output:

Let's see
1
1
3
5
13