In this lesson, you will learn a little bit more about the
enumerate() function is a built-in function. That means you don’t need to import it to use it in Python. It requires an object that supports iteration.
seasons variable was a perfect example for this. The
seasons variable is a list and therefore iterable Also, the
enumerate() function accepts
start as an optional argument.
If you don’t use this optional argument, the
enumerate() function will just start to count by
0. But if you pass something in, like you did in the last lesson, you can say that it starts with
enumerate() function returns an iterator. What exactly this means you will find out in one of the next lessons. Also it yields a tuple:
You already saw this by printing
season in your last script that you wrote. What exactly yielding is you also will learn in one of the next lessons. And to get an even better understanding of the
enumerate() function, you will build your very own variant of it in the next lesson.
Become a Member to join the conversation.