generator - unbound count (with yield)
def count(start=0, step=1):
n = start
while True:
yield n
n += step
for c in count(start=19, step=1):
print(c)
if c > 23:
break
Output:
19
20
21
22
23
24
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
def count(start=0, step=1):
n = start
while True:
yield n
n += step
for c in count(start=19, step=1):
print(c)
if c > 23:
break
Output:
19
20
21
22
23
24