🌐
Python Tips
book.pythontips.com › en › latest › enumerate.html
13. Enumerate — Python Tips 0.1 documentation
my_list = ['apple', 'banana', 'grapes', 'pear'] counter_list = list(enumerate(my_list, 1)) print(counter_list) # Output: [(1, 'apple'), (2, 'banana'), (3, 'grapes'), (4, 'pear')]
🌐
Codecademy
codecademy.com › docs › python › built-in functions › enumerate()
Python | Built-in Functions | enumerate() | Codecademy
April 14, 2025 - The enumerate() function is a built-in Python function that adds a counter to an iterable and returns it as an enumerate object. It takes an iterable object (like a list, tuple, or string) and returns a sequence of tuples containing indices ...
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › functions › enumerate.html
enumerate — Python Reference (The Right Way) 0.1 documentation
Docs » · enumerate · Edit on GitHub · Returns an enumerate object. enumerate (sequence, start=0) sequence · Required. Must be a sequence, an iterator, or some other object which supports iteration. start · Optional. Index at which enumeration starts. #TODO · #TODO ·
🌐
W3Schools
w3schools.com › python › ref_func_enumerate.asp
Python enumerate() Function
The enumerate() function adds a counter as the key of the enumerate object. ... Coding fundamentals as bite-sized lessons and challenges. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an ...
🌐
Real Python
realpython.com › python-enumerate
Python enumerate(): Simplify Loops That Need Counters – Real Python
October 21, 2025 - Your version of enumerate() has two requirements. It should: Accept an iterable and a starting count value as arguments · Send back a tuple with the current count value and the associated item from the iterable · One way to write a function that meets these specifications is given in the Python documentation...
🌐
Vultr Docs
docs.vultr.com › python › built-in › enumerate()
Python enumerate() - Iterate With Index
December 5, 2024 - The enumerate() function in Python adds a counter to an iterable and returns it in a form of an enumerate object.
🌐
Python
docs.python.org › 2.3 › whatsnew › section-enumerate.html
7 PEP 279: enumerate()
PEP 279, The enumerate() built-in function · Written and implemented by Raymond D. Hettinger. Previous: 6 PEP 278: Universal Up: What's New in Python Next: 8 PEP 282: The · Release 1.01. See About this document...
🌐
GeeksforGeeks
geeksforgeeks.org › python › enumerate-in-python
Enumerate() in Python - GeeksforGeeks
The enumerate() function in Python is used to iterate over an iterable while keeping track of both the index and the value. It returns pairs in the form (index, element).
Published: May 8, 2026
🌐
Coursera
coursera.org › tutorials › how to enumerate in python: step by step
How to Enumerate in Python: Step by Step | Coursera
February 24, 2023 - Prerequisites/helpful expertise: Basic knowledge of Python and programming concepts · Enumerate is a built-in Python function.
Find elsewhere
🌐
Programiz
programiz.com › python-programming › methods › built-in › enumerate
Python enumerate()
Online Python Online JavaScript ... Online Scala Online Dart Online R Online Ruby ... The enumerate() function adds a counter to an iterable and returns it as an enumerate object (iterator with index and the value)....
🌐
Hackr
hackr.io › home › articles › programming › python
Python enumerate() Function | Docs With Examples
February 10, 2025 - The enumerate() function adds indices to your iterations effortlessly. The start parameter lets you control the starting index, adding extra flexibility. It works with any iterable object, including lists, tuples, and strings, making it extremely ...
🌐
Python
docs.python.org › 3 › builtins › functions.html
Built-in Functions — Python 3.14.7 documentation
Return an enumerate object. iterable must be a sequence, an iterator, or some other object which supports iteration.
🌐
Towards Data Science
towardsdatascience.com › home › latest › python enumerate() built-in-function
Python enumerate() built-in-function | Towards Data Science
January 31, 2025 - Enumerate function also accepts optional arguments, you can also pass the name of the data structure along with the specific index which you want to start the counter from. For example, think that the default value of the list starts from 0 and then the counter continues to iterate. Now you want to start the counter from 5 and then increment it. This can be done as shown below: programmming = ["Python", "Programmming", "Is", "Fun"]
🌐
Codecademy
codecademy.com › forum_questions › 5087f2d786a27b02000041a9
So what exactly does enumerate do? | Codecademy
enumerate() is one of the built-in Python functions. It returns an enumerate object. In our case that object is a list of tuples (immutable lists), each containing a pair of count/index and value.
🌐
Python Basics
pythonbasics.org › home › python basics › enumerate explained (with examples)
Enumerate Explained (With Examples) - pythonbasics.org
The enumerate() function is a built-in function that returns an enumerate object. 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 ...
Top answer
1 of 8
538

The enumerate() function adds a counter to an iterable.

So for each element in cursor, a tuple is produced with (counter, element); the for loop binds that to row_number and row, respectively.

Demo:

>>> elements = ('foo', 'bar', 'baz')
>>> for elem in elements:
...     print elem
... 
foo
bar
baz
>>> for count, elem in enumerate(elements):
...     print count, elem
... 
0 foo
1 bar
2 baz

By default, enumerate() starts counting at 0 but if you give it a second integer argument, it'll start from that number instead:

>>> for count, elem in enumerate(elements, 42):
...     print count, elem
... 
42 foo
43 bar
44 baz

If you were to re-implement enumerate() in Python, here are two ways of achieving that; one using itertools.count() to do the counting, the other manually counting in a generator function:

from itertools import count

def enumerate(it, start=0):
    # return an iterator that adds a counter to each element of it
    return zip(count(start), it)

and

def enumerate(it, start=0):
    count = start
    for elem in it:
        yield (count, elem)
        count += 1

The actual implementation in C is closer to the latter, with optimisations to reuse a single tuple object for the common for i, ... unpacking case and using a standard C integer value for the counter until the counter becomes too large to avoid using a Python integer object (which is unbounded).

2 of 8
98

It's a builtin function that returns an object that can be iterated over. See the documentation.

In short, it loops over the elements of an iterable (like a list), as well as an index number, combined in a tuple:

for item in enumerate(["a", "b", "c"]):
    print item

prints

(0, "a")
(1, "b")
(2, "c")

It's helpful if you want to loop over a sequence (or other iterable thing), and also want to have an index counter available. If you want the counter to start from some other value (usually 1), you can give that as second argument to enumerate.

🌐
freeCodeCamp
freecodecamp.org › news › what-is-enumerate-in-python
What is enumerate() in Python? Enumeration Example
December 22, 2022 - enumerate() will return an enumerate object which essentially holds a list of tuples. Each tuple contains an item from the iterable and the item's count value. For more details on the input arguments and variations, you can refer to the ...
🌐
DataCamp
datacamp.com › tutorial › python-enumerate-tutorial
Python Enumerate Tutorial | DataCamp
May 20, 2022 - The enumerate() function is a Python built-in function that takes an iterable (a collection of items or any other Python object that supports iteration, such as tuples, lists, sets, or strings), iterates through its items under the hood, and returns an enumerate object.
🌐
YouTube
youtube.com › watch
Master Python enumerate() Function: 10 Practical Examples - YouTube
🧠 Don’t miss out! Get FREE access to my Skool community — packed with resources, tools, and support to help you with Data, Machine Learning, and AI Automati...
Published: October 15, 2024