...
/takewhile(), tee() and zip_longest()
takewhile(), tee() and zip_longest()
Let's figure out the iterators that do not terminate. i.e. takewhile(), tee() and zip_longest().
We'll cover the following...
takewhile(predicate, iterable)
The takewhile
module is basically the opposite of the dropwhile
iterator that we looked at earlier. takewhile
will create an iterator that returns elements from the iterable only as long as our predicate or filter is True
. Let’s try a simple example to see how it works:
Access this course and 1400+ top-rated courses and projects.