# itertools Module

In this lesson, you’ll learn about the `itertools` module. This module helps you create iterators for efficient looping:

Python
``````>>> import itertools as it
>>> rep = it.repeat(1)
>>> next(rep)
1
>>> next(rep)
1
``````
Copied!

• `itertools.cycle`, which infinitely cycles through iterables
• `itertools.permutations`, which finds all the permutations (order matters)
• `itertools.combinations`, which finds all the combinations (order does not matter)

You can check out the Python documentation on the `itertools` module.

James Uejio RP Team

Here is the Python documentation on the `itertools` module: Python itertools module

Pygator

Lot’s of helpful hints/tips, but talking so fast does not help me learn it faster.

drawdoowmij

Hi James – Great video, at 1:10 you say “list calls the next method on a map object” can you let me know where in the documentation you found this. Thanks!

James Uejio RP Team

Hi @Pygator I will keep my speed in mind in the future, but for the current videos you can go to the gear icon and select 0.75x speed if it is too fast for you.

@drawdoowmij I can’t really find Python documentation on where this happens but I learned it in school here: www.youtube.com/watch?v=On-kFyFp8HY&list=PL6BsET-8jgYWPYsrAfTAN8rvBzk5cYfUZ&index=2. You can also see it answered here stackoverflow.com/questions/34732641/calling-list-empties-my-iterable-object. Plus you can see in the following example that list has to call next because it empties the iterator

``````>>> iterator = iter([1,2,3])
>>> next(iterator)
1
>>> list(iterator)
[2, 3]
>>> next(iterator)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StopIteration
``````

drawdoowmij

Thanks for this information James!

to join the conversation.

Lesson Completed!
Lesson Bookmarked
Request Failed :(