Fibonacci sequences using generators : Yield : Statement PYTHON TUTORIALS


PYTHON TUTORIALS » Statement » Yield »

 

Fibonacci sequences using generators


def fibonacci(max):
    a, b = 01
    while a < max:
        yield a
        a, b = b, a+b

for n in fibonacci(1000):
    print n,



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Statement
» Yield