mirror of
https://github.com/Hizenberg469/Python-tutorial.git
synced 2026-04-19 23:12:24 +03:00
generator done
This commit is contained in:
11
generators/fibonacci.py
Normal file
11
generators/fibonacci.py
Normal file
@@ -0,0 +1,11 @@
|
||||
def fib(number):
|
||||
a = 0
|
||||
b = 1
|
||||
for i in range(number):
|
||||
yield a
|
||||
temp = a
|
||||
a = b
|
||||
b = temp + b
|
||||
|
||||
for x in fib(20):
|
||||
print(x)
|
||||
Reference in New Issue
Block a user