Understanding enumerate()
00:00
In this lesson, you will learn a little bit more about the enumerate()
function.
00:06
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.
00:17
The 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.
00:31
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 1
.
00:45
Also the enumerate()
function returns an iterator. What exactly this means you will find out in one of the next lessons. Also it yields a tuple: count
and value
`.
00:57
You already saw this by printing count
and 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.