Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Python Sequences!
You have completed Python Sequences!
Preview
Learn about the enumerate function, another tool to iterate over sequences.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
In this video,
we're gonna be expanding on the for
0:00
loop a little bit to talk
about the enumerate function.
0:01
The enumerate function comes in
handy when we need to know the index
0:04
of the current element in our loop.
0:07
Or we want some kind of counter.
0:09
Let's look at this grocery
list example again.
0:11
We have this list, and that's all well and
good, but I want it to print out nice, and
0:13
neat, and numbered.
0:17
How do I get the numbers?
0:18
Well, here's one potential option
that we're going to explore and
0:20
then improve on.
0:23
So, first we can create a variable
to store our counter number.
0:25
We'll assign the integer one to it
because most grocery lists start at one.
0:28
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up