File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 11# Itertools
22This section will go over a few tools in python 3's itertools library.
33
4+ ## Iterables vs. Iterators
5+
6+ Before we begin, you can't understand itertools unless you understand iterators and iterables.
7+
8+ ### Iterables
9+
10+ ### Iterators
11+ Iterators is an object which can iterate over an iterable.
12+ You can create an iterator with the ** iter()** method.
13+ You can iterate by implementing the ** __ next__ ()** method, this returns the next item in the object.
14+
15+ When you use a for loop, you are actually using an iterator. An iterator is created for you and loop across your iterable.
16+ When an iterator reaches the end of the list, it will automatically throw a StopIteration exception.
17+ The for loop catches that exception and exits gracefully.
18+
419## count()
520
621## cycle()
You can’t perform that action at this time.
0 commit comments