File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 1
1
# Itertools
2
2
This section will go over a few tools in python 3's itertools library.
3
3
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
+
4
19
## count()
5
20
6
21
## cycle()
You can’t perform that action at this time.
0 commit comments