Kapitel 18: Generatoren und list comprehension

This commit is contained in:
2023-06-08 19:38:09 +02:00
parent 9e78b44184
commit 124bff5e06
9 changed files with 62 additions and 0 deletions

15
teil18/fib_gen.py Normal file
View File

@@ -0,0 +1,15 @@
import sys
def fib_generator():
a,b = 0,1
while True:
yield a
a,b = b, a+b
fibo = fib_generator()
for _ in range(int(sys.argv[1])):
print(next(fibo))