Try this:

Use with AI[(i, j) for i, j in enumerate(mylist)]

You need to put i,j inside a tuple for the list comprehension to work. Alternatively, given that enumerate() already returns a tuple, you can return it directly without unpacking it first:

Use with AI[pair for pair in enumerate(mylist)]

Either way, the result that gets returned is as expected:

Use with AI> [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'd')]
Answer from Óscar López on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › enumerate-in-python
Enumerate() in Python - GeeksforGeeks
Explanation: list(enumerate(a)) converts index-element pairs into a list of tuples.
Published: May 8, 2026
🌐
Real Python
realpython.com › python-enumerate
Python enumerate(): Simplify Loops That Need Counters – Real Python
June 23, 2025 - >>> values = ["first", "second"] >>> enumerate_instance = enumerate(values) >>> print(enumerate_instance) <enumerate at 0x7fe75d728180> >>> next(enumerate_instance) (0, 'first') >>> next(enumerate_instance) (1, 'second') >>> next(enumerate_instance) Traceback (most recent call last): File "<python-input-5>", line 1, in <module> next(enumerate_instance) ~~~~^^^^^^^^^^^^^^^ StopIteration · In this example, you create a Python list called values with two elements, "first" and "second".
Discussions

Hello, a complete novice to python. Can someone explain why to enumerate returns the memory address and the enumerated object?
Because you’re printing the object that you created. You need to iterate through it. From the docs Return an enumerate object Python Docs -Enumerate More on reddit.com
🌐 r/learnpython
6
1
November 21, 2022
Python using enumerate inside list comprehension - Stack Overflow
Lets suppose I have a list like this: mylist = ["a","b","c","d"] To get the values printed along with their index I can use Python's enumerate function like this >>> for i,j in enumerate( More on stackoverflow.com
🌐 stackoverflow.com
range(len(s)) vs enumerate?
Oldie but goodie: https://youtu.be/EnSu9hHGq5o Loop like a native: while, for, iterators, generators presented by Ned Batchelder More on reddit.com
🌐 r/learnpython
35
26
May 28, 2021
Enumerate()
In short: enumerate adds a counter to an iterable and you can give an optional parameter (default: 0) where to start to count. Example: letters = ['a', 'b', 'c', 'd', 'e', 'f'] for counter, item in enumerate(letters, start=3): print(counter, item) output: (3, 'a') (4, 'b') (5, 'c') (6, 'd') (7, 'e') (8, 'f') More on reddit.com
🌐 r/learnpython
17
15
November 21, 2018
🌐
Enki
enki.com › post › what-does-enumerate-mean-in-python
Enki | Blog - What Does enumerate Mean in Python
The enumerate() function is a Python tool that allows you to loop through an iterable—like a list, tuple, or string—and have access to both the index and the element itself.
🌐
Medium
medium.com › @datasciencejourney100_83560 › enumerate-function-in-py-1289137117e9
Enumerate Function in Python. The enumerate() function in Python is a… | by Rina Mondal | Medium
August 30, 2025 - The enumerate() function in Python is a built-in function that allows you to iterate over an iterable (such as a list, tuple, or string) while also keeping track of the index of each item in the iterable.
🌐
Mimo
mimo.org › glossary › python › enumerate-function
Python enumerate(): Loop with an Index and start=
The built-in enumerate() function in Python adds a counter to a sequence and returns the combination as an enumerate object. The enumerate() function takes a sequence like a list, tuple, or string, and returns an enumerate object.
🌐
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 e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
Find elsewhere
🌐
Coursera
coursera.org › tutorials › how to enumerate in python: step by step
How to Enumerate in Python: Step by Step | Coursera
February 24, 2023 - By default, the syntax of Python enumerate is as follows: ... You can adjust the enumerate function to fit your needs by changing its parameters. Enumerate has two parameters: 1. Iterable: The iterable is the sequence, list, or objects you select to enumerate.
🌐
YouTube
youtube.com › watch
What does Python's "enumerate" do? - YouTube
Wondering where the indexes have gone in Python's "for" loops, and how you can get them back? In this video, I show you "enumerate", the builtin designed to ...
Published: June 10, 2022
🌐
freeCodeCamp
freecodecamp.org › news › what-is-enumerate-in-python
What is enumerate() in Python? Enumeration Example
December 22, 2022 - By Suchandra Datta The enumerate() function is one of the built-in functions in Python. It provides a handy way to access each item in an iterable, along with a count value that specifies the order in which the item was accessed. In this article ...
🌐
freeCodeCamp
freecodecamp.org › news › python-enumerate-what-is-the-enumerate-function-in-python
Python enumerate() – What is the Enumerate Function in Python?
June 8, 2022 - The enumerate() function in Python takes in a data collection as a parameter and returns an enumerate object. The enumerate object is returned in a key-value pair format. The key is the corresponding index of each item and the value is the items.
🌐
Analytics Vidhya
analyticsvidhya.com › home › python enumerate(): simplify looping with counters
Python enumerate(): Simplify Looping With Counters | Analytics Vidhya
July 12, 2024 - A. In Python, the enumerates function enumerates objects. Enumerated returns objects containing counters for each value in objects, making items in collections easier to locate. Keys indicate the contents of a list.
🌐
Plain English
python.plainenglish.io › understanding-pythons-enumerate-examples-and-use-cases-1ea7c30276c1
Understanding Python’s enumerate: Examples and Use Cases | Python in Plain English
January 20, 2025 - names = ["John", "Ben", "Alice"] for index, name in enumerate(names): print(str(index+1) + "-" + name, end=" ")… · The author made this story available to Medium members only. If you’re new to Medium, create a new account to read this story on us. ... An automation engineer and derivative trader with a passion for writing about everything. ... New Python content every day.
🌐
Markdown Guide
markdownguide.org › basic-syntax
Basic Syntax | Markdown Guide
The numbers don’t have to be in numerical order, but the list should start with the number one.
🌐
PrepBytes
prepbytes.com › home › python › enumerate function in python
Enumerate Function in Python
June 30, 2023 - The enumerate() function in Python is a built-in method that provides an elegant way to iterate over a sequence while keeping track of the index or position of each element. It takes an iterable (such as a list, tuple, or string) as input and ...
🌐
Reddit
reddit.com › r › learnpython › comments › 6qty5y › what_does_enumerate_do_in_python
What does enumerate do in python? : r/learnpython
Subreddit for posting questions and asking for general advice about all topics related to learning python.
🌐
Matplotlib
matplotlib.org › stable › gallery › color › named_colors.html
List of named colors — Matplotlib 3.11.2 documentation
import math import matplotlib.pyplot as plt import matplotlib.colors as mcolors from matplotlib.patches import Rectangle def plot_colortable(colors, *, ncols=4, sort_colors=True): cell_width = 212 cell_height = 22 swatch_width = 48 margin = 12 # Sort colors by hue, saturation, value and name. if sort_colors is True: names = sorted( colors, key=lambda c: tuple(mcolors.rgb_to_hsv(mcolors.to_rgb(c)))) else: names = list(colors) n = len(names) nrows = math.ceil(n / ncols) width = cell_width * ncols + 2 * margin height = cell_height * nrows + 2 * margin dpi = 72 fig, ax = plt.subplots(figsize=(widt
🌐
Python documentation
docs.python.org › 3 › tutorial › controlflow.html
4. More Control Flow Tools — Python 3.15.2 documentation
>>> list(range(5, 10)) [5, 6, 7, 8, 9] >>> list(range(0, 10, 3)) [0, 3, 6, 9] >>> list(range(-10, -100, -30)) [-10, -40, -70] To iterate over the indices of a sequence, you can combine range() and len() as follows: >>> a = ['Mary', 'had', 'a', 'little', 'lamb'] >>> for i in range(len(a)): ... print(i, a[i]) ... 0 Mary 1 had 2 a 3 little 4 lamb · In most such cases, however, it is convenient to use the enumerate() function, see Looping Techniques.