On top of the already provided answers there is a very nice pattern in Python that allows you to enumerate both keys and values of a dictionary.

The normal case you enumerate the keys of the dictionary:

Use with AIexample_dict = {1:'a', 2:'b', 3:'c', 4:'d'}

for i, k in enumerate(example_dict):
    print(i, k)

Which outputs:

Use with AI0 1
1 2
2 3
3 4

But if you want to enumerate through both keys and values this is the way:

Use with AIfor i, (k, v) in enumerate(example_dict.items()):
    print(i, k, v)

Which outputs:

Use with AI0 1 a
1 2 b
2 3 c
3 4 d
Answer from João Almeida on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › iterate-python-dictionary-using-enumerate-function
Iterate Python Dictionary Using Enumerate() Function - GeeksforGeeks
July 23, 2025 - In this example, a generator expression is used within the enumerate() function to filter dictionary elements based on a condition. In this case, only cities with a population greater than 3 million are included in the iteration. This showcases how enumerate() can be combined with other Python features to perform more complex operations during iteration.
🌐
Coursera
coursera.org › tutorials › how to enumerate in python: step by step
How to Enumerate in Python: Step by Step | Coursera
February 24, 2023 - 1 2 3 4 programs = ['python','c','react','javascript','bash'] for i, program in enumerate(programs,1): print(i, program) ... Enumerate objects are immutable, which means you cannot change, remove, or add values to them. There are two ways to enumerate a dictionary in Python.
🌐
Reddit
reddit.com › r/learnpython › how to loop through dict with enumerate and unpack the index, key, and value
r/learnpython on Reddit: how to loop through dict with enumerate and unpack the index, key, and value
October 13, 2022 -

an example of the dict

{10: {'total_power_usage': 152.1, 'total_pris': 336.62499999999994, 'huse_usage': 74.45588194444376, 'hus_pris': 195.42238509638779, 'charge_usage': 77.64411805555619, 'charge_price_full': 141.1951349036122, 'charge_price': 63.55101684805601}}

now i can do :

for i, (k, v) in enumerate(my_result.items()):
    print("index: {}, key: {}, value: {}".format(i, k, v))

and that prints each line in the dict just fine. But how do i access each named element in the dict? if i need the value from 'total_pris' or 'charge_usage' ?

🌐
freeCodeCamp
freecodecamp.org › news › what-is-enumerate-in-python
What is enumerate() in Python? Enumeration Example
December 22, 2022 - First, let's look at enumerate(iterable, start=0). ... an iterable, such as a list, tuple, string, dictionary or any object which has the __next__ and __iter__ methods defined (which means it supports iteration).
🌐
YouTube
youtube.com › john f. mcgowan, ph.d.
Python enumerate and dictionaries - YouTube
Short video on how the Python enumerate() function works with Python dictionaries which can be confusing. See this blog post:Legal Disclaimers: http://wordp...
Published: June 18, 2019
Views: 900
Find elsewhere
🌐
Python documentation
docs.python.org › 3 › tutorial › datastructures.html
5. Data Structures — Python 3.15.2 documentation
4 weeks ago - A pair of braces creates an empty dictionary: {}. Placing a comma-separated list of key:value pairs within the braces adds initial key:value pairs to the dictionary; this is also the way dictionaries are written on output.
🌐
Towards Data Science
towardsdatascience.com › home › programming › python enumerate() function, explained
Python enumerate() Function, Explained | Towards Data Science
February 20, 2023 - While key-value pairs in the dictionary are not ordered and not indexed, using enumerate() can be a very useful option for your code. The main difference in the output is that when iterating over a dictionary, you have the option of iterating over dictionary keys, dictionary values, or dictionary key-value pairs.
🌐
Pierian Training
pieriantraining.com › home › enumerating dictionaries in python
Enumerating Dictionaries in Python - Pierian Training
April 28, 2023 - As you can see, enumerating dictionaries using for loops is a simple and effective way to access and manipulate their contents. Python provides several ways to enumerate dictionaries, and one of the most efficient ways is using list comprehension.
🌐
Real Python
realpython.com › iterate-through-dictionary-python
How to Iterate Through a Dictionary in Python – Real Python
September 9, 2025 - By understanding these techniques, ... You can directly iterate over the keys of a Python dictionary using a for loop and access values with dict_object[key]....
🌐
Medium
medium.com › @kerinmulianto › exploring-pythons-enumerate-a-beginner-s-guide-62f1c9265e45
Exploring Python’s enumerate: A Beginner’s Guide | by Kerinmulianto | Medium
November 24, 2024 - This guide introduces Python’s enumerate function, which simplifies tracking indices while iterating through lists, tuples, and strings. It provides examples for using enumerate with lists, dictionaries, and strings, showing how it makes code cleaner and more efficient compared to manually managing indices.
🌐
Mathspp
mathspp.com › blog › pydonts › enumerate-me
Enumerate me | Pydon't 🐍 | mathspp
April 6, 2021 - the result of enumerate can be fed directly to dict to create a dictionary whose keys are the indices; using enumerate we get a nice idiom to find the indices of an iterable that point to the elements that satisfy a given condition; and · coupling zip, enumerate, and deep unpacking allows you to loop over several iterables elegantly. If you liked this Pydon't be sure to leave a reaction below and share this with your friends and fellow Pythonistas.
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › iterate python dictionary using enumerate() function
Iterate Python Dictionary using enumerate() Function - Spark By {Examples}
May 31, 2024 - You can iterate a Python dictionary using the enumerate() function. which is used to iterate over an iterable object or sequence such as a list,
🌐
Programiz
programiz.com › python-programming › methods › built-in › enumerate
Python enumerate() | Programiz
February 20, 2024 - The enumerate() function adds a counter to an iterable and returns the enumerate object. In this tutorial, we will learn about the Python enumerate() function with the help of examples.
🌐
Merriam-Webster
merriam-webster.com › dictionary › enumerate
ENUMERATE Definition & Meaning - Merriam-Webster
October 10, 2026 - Simple Definition A Simple Definition is available from our Learner's Dictionary to help you understand the meaning faster. ... In a census year, the U.S. government attempts to enumerate every single citizen of the country—a task that, even in the modern era of technology, isn't truly possible.
🌐
Built In
builtin.com › software-engineering-perspectives › convert-list-to-dictionary-python
10 Ways to Convert Lists to Dictionaries in Python | Built In
Let’s see how to convert a Python list to a dictionary. Converting a list of tuples to a dictionary. Converting two lists of the same length to a dictionary. Converting two lists of different length to a dictionary. Converting a list of alternative key, value items to a dictionary. Converting a list of dictionaries to a single dictionary. Converting a list into a dictionary using enumerate().
🌐
Quora
quora.com › Can-you-enumerate-a-dictionary-in-Python
Can you enumerate a dictionary in Python? - Quora
Answer (1 of 7): A simple Google search for python enumerate dictionary matched 597,000 pages. Mercifully, Google displays the pages it judges most relevant first in its list, and it tends to be a pretty good judge of relevance. Among the highest ranked of the pages was: Python Enumerate Expl...
🌐
Onestopdataanalysis
onestopdataanalysis.com › home › enumerate dictionary python
Enumerate Dictionary Python: Everything You need about it
Python Enumerate command was unknown to me for a long time. On this recipe, you will learn how to use it when using a for loop … ... A blog containing scripts and data analysis lessons such as Bioinformatics, Python, GitHub, Docker, Machine Learning, etc.