Recipe 2.15. Generating a Sequence of Numbers
2.15.1. Problem
You want to iterate over a (possibly infinite) sequence of
numbers the way you can iterate over an array or a range.
2.15.2. Solution
Write a generator function that yields each number in the sequence.
You are currently reading a PREVIEW of this book.
Get instant access to over
$1 million worth of books and videos.
Start a Free Trial