Hopefully this clarifies what exactly enumerate does:

>>> list(enumerate('abc'))
[(0, 'a'), (1, 'b'), (2, 'c')]

It just turns your list into a list of a pairs where each of your elements is joined with the index i.e. a with 0, b with 1 and c with 2.

That's not exactly true because it is an iterator rather than an actual list - so it provides you with values lazily when you wrap another iterator.

Looping over it is therefore the same as any other lists except usually it is done the following way:

for i, x in enumerate(xs)

You could still use:

for i in enumerate(xs)

but then just know that i is going to be a tuple with some int, and some object from xs.

Answer from rudolfovic on Stack Overflow
🌐
Real Python
realpython.com › python-enumerate
Python enumerate(): Simplify Loops That Need Counters – Real Python
June 23, 2025 - Since the count is a standard Python integer, you can use it in many ways. ... Now that you’ve explored the basics of enumerate(), it’s time to practice using enumerate() with some real-world examples. Using conditional statements to process items can be a very powerful technique. Sometimes, you might need to perform an action on only the very first iteration of a loop, as shown in this example: ... >>> tasks_by_priority = ["Pay Rent", "Clean Dishes", "Buy Milk"] >>> for index, task in enumerate(tasks_by_priority): ...
🌐
freeCodeCamp
freecodecamp.org › news › python-enumerate-python-enum-for-loop-index-example
Python Enumerate – Python Enum For Loop Index Example
September 22, 2021 - Instead of incrementing a count variable ourselves, we can use the enumerate() function with the for loop. Python's built in enumerate() function takes in an iterable and an optional start argument.
🌐
GeeksforGeeks
geeksforgeeks.org › python › enumerate-in-python
Enumerate() in Python - GeeksforGeeks
enumerate() function in Python is used to loop over an iterable and get both the index and the element at the same time. It returns an enumerate object that produces pairs in the form (index, element).
Published   July 12, 2017
🌐
Nb-Data
nb-data.com › p › 6-ways-to-use-pythons-enumerate-for
6 Ways to Use Python's enumerate for Better Loop Control - NBD Lite #28
October 14, 2024 - Without using enumerate, we would need a manual counter that makes the code less efficient. That’s why we could rely on enumerate looping through the index and values. Below is a code example of how to do that. data = ['apple', 'banana', 'cherry'] for i, fruit in enumerate(data): print(f"Index {i}: {fruit}")
🌐
Great Learning
mygreatlearning.com › blog › it/software development › python enumerate(): simplify looping with counters
Python enumerate(): Simplify Looping With Counters
January 6, 2025 - Here's an example of how to use an enumerate object to loop through a list: enumerate_obj = enumerate(iterable) for index, value in enumerate_obj: # Do something with index and value
🌐
Programiz
programiz.com › python-programming › methods › built-in › enumerate
Python enumerate()
grocery = ['bread', 'milk', 'butter'] for item in enumerate(grocery): print(item) print() # loop over an enumerate object for count, item in enumerate(grocery): print(count, item) print()
🌐
Towards Data Science
towardsdatascience.com › home › latest › looping in python
Looping in Python | Towards Data Science
January 20, 2025 - Instead of using the range() function, we can instead use the built-in enumerate() function in python. enumerate() allows us to iterate through a sequence but it keeps track of both the index and the element.
Find elsewhere
🌐
Analytics Vidhya
analyticsvidhya.com › home › python enumerate(): simplify looping with counters
Python enumerate(): Simplify Looping With Counters | Analytics Vidhya
July 12, 2024 - In this case, the student_scores dictionary’s key-value pairs are returned in a tuple by the function enumerate(student_scores.items()). You can rank students according to their scores by iterating through these pairs in the for loop. ... enumerate() is also valuable when working with strings. You can efficiently process substrings, words, or characters within a string: sentence = "Python is amazing!" for index, word in enumerate(sentence.split()): print(f"Word {index + 1}: {word}")
🌐
datagy
datagy.io › home › python posts › python enumerate: python looping with index counters
Python enumerate: Python Looping with Index Counters • datagy
February 15, 2023 - The Python enumerate() function allows you to loop over an iterable object, such as lists or dictionaries while accessing the item’s index position. The enumerate() function lets you write significantly cleaner Python for-loops.
🌐
Stack Abuse
stackabuse.com › guide-to-enumerate-in-python-forget-loops-with-counters
Guide to enumerate() in Python - Easy for Loops with Counting
January 31, 2022 - You can, without any extra dependencies, loop through an iterable in Python, with an automatic counter variable/index with syntax as simple as: for idx, element in enumerate(some_list): print(idx, element)
🌐
Sololearn
sololearn.com › en › Discuss › 1899313 › for-loop-including-enumerate-methodpython
For loop including enumerate method(Python) | Sololearn: Learn to code for FREE!
So just some more information about ... like 2 for first iteration, 4 for second iteration ... now you can use p and n to do something during each iteration loop......
🌐
Python.org
discuss.python.org › python help
Enumerate explanation - Python Help - Discussions on Python.org
August 23, 2022 - I was trying to find a way to iterate through a string and return a specific character when only unique characters of the string were detected and another character if duplicates were detected (basically encoding the word “cheese” into “(())()” I started diving into nested loops with counts and sets and trying to figure out how to then produce one character or another depending on which list the iteration was found in, but I came across “enumerate”, which from what I’ve read has the ability to...
🌐
Guru99
guru99.com › home › python › enumerate() function in python: loop, tuple, string (example)
Enumerate() Function in Python: Loop, Tuple, String (Example)
August 12, 2024 - The Python Enumerate() command adds a counter to each item of the iterable object and returns an enumerate object as an output string. ... Iterable: an object that can be looped. StartIndex: (optional) The count will start with the value given in the startIndex for the first item in the loop ...
🌐
Note.nkmk.me
note.nkmk.me › home › python
How to Start enumerate() at 1 in Python | note.nkmk.me
May 6, 2023 - step = 3 for i, name in enumerate(l): print(i * step, name) # 0 Alice # 3 Bob # 6 Charlie
🌐
Coursera
coursera.org › tutorials › enumerate-python
How to Enumerate in Python: Step by Step | Coursera
The for loop unpacks each pair into i and fruit variables, where i is the index and fruit is the corresponding item. Try writing a program that returns the following output: ... 1 2 3 4 programs = ['python','c','react','javascript','bash'] for ...
🌐
Python Basics
pythonbasics.org › enumerate
Enumerate Explained (With Examples) - Python Tutorial
This lets you get the index of an element while iterating over a list. In other programming languages (C), you often use a for loop to get the index, where you use the length of the array and then get the index using that. That is not Pythonic, instead you should use enumerate().
🌐
Mimo
mimo.org › glossary › python › enumerate-function
Python enumerate Function: Master Index-Based Iteration
Master Python's enumerate() function to iterate with indexes. Simplify loops, track positions, and improve code readability with practical examples.
🌐
Afternerd
afternerd.com › blog › python-enumerate
Python Enumerate Explained (With Examples) - Afternerd
August 20, 2019 - That’s why when we iterate over the enumerate object with a for loop like this: >>> for idx, val in enumerate(['a', 'b']): ... print(idx, val) ... 0 a 1 b · We are effectively unpacking these tuples to an index and a value. But there is nothing that prevents you from doing this (but don’t do it :)) >>> for i in enumerate(['a', 'b']): ... print(i[0], i[1]) ... 0 a 1 b ... Check out the Courses section! The Python Learning Path (From Beginner to Mastery)
🌐
Simplilearn
simplilearn.com › home › resources › software development › an introduction to enumerate in python with syntax and examples
An Introduction to Enumerate in Python with Syntax and Examples
August 24, 2025 - Enumerate is a built-in function in the python library. This tutorial will help you to learn all about enumerate in python with syntax and examples. Start now!