Generator with yield
We don't even need to use a temporary variable for it.
def number():
yield 42
yield 19
yield 23
for n in number():
print(n)
Output:
42
19
23
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
We don't even need to use a temporary variable for it.
def number():
yield 42
yield 19
yield 23
for n in number():
print(n)
Output:
42
19
23