Pulling it all together

Before we summarize, let's pull a few pieces of what we have made together and leave your computer computing the Lucas primes:

>>> for x in (p for p in lucas() if is_prime(p)):
... print(x)
...
2
3
7
11
29
47
199
521
2207
3571
9349
3010349
54018521
370248451
6643838879
119218851371
5600748293801
688846502588399
32361122672259149

When you've seen enough of these, we recommend you spend some time exploring the itertools module. The more you familiarize yourself with Python's existing support for iterables, the more elegant and concise your own code will become.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset