You could just iterate over the indices of the range of the len of your list:

dataList = [{'a': 1}, {'b': 3}, {'c': 5}]
for index in range(len(dataList)):
    for key in dataList[index]:
        print(dataList[index][key])

or you could use a while loop with an index counter:

dataList = [{'a': 1}, {'b': 3}, {'c': 5}]
index = 0
while index < len(dataList):
    for key in dataList[index]:
        print(dataList[index][key])
    index += 1

you could even just iterate over the elements in the list directly:

dataList = [{'a': 1}, {'b': 3}, {'c': 5}]
for dic in dataList:
    for key in dic:
        print(dic[key])

It could be even without any lookups by just iterating over the values of the dictionaries:

dataList = [{'a': 1}, {'b': 3}, {'c': 5}]
for dic in dataList:
    for val in dic.values():
        print(val)

Or wrap the iterations inside a list-comprehension or a generator and unpack them later:

dataList = [{'a': 1}, {'b': 3}, {'c': 5}]
print(*[val for dic in dataList for val in dic.values()], sep='\n')

the possibilities are endless. It's a matter of choice what you prefer.

Answer from MSeifert on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_dictionaries_loop.asp
Python - Loop Dictionaries
You can loop through a dictionary by using a for loop. When looping through a dictionary, the return value are the keys of the dictionary, but there are methods to return the values as well.
Discussions

Loops, arrays, dictionaries -- oh my
Is there a way to carry out this set of instructions using a list or dictionary? Or what would your approach be to make the code more efficient? Thx! More on discuss.python.org
๐ŸŒ discuss.python.org
0
0
October 12, 2022
python - How to loop in array of dictionaries in a list - Stack Overflow
Trying to loop in an array of dictionary in list I am getting this error message: TypeError: list indices must be integers or slices, not dict What am I doing wrong here? cars = [ { &... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Iterate through list of dictionaries and get key and value.

Try r/learnpython for learning the language. This sub is more focused on news according to the sidebar.

More on reddit.com
๐ŸŒ r/Python
10
0
May 20, 2016
How can I loop through a list and basically make a dictionary/hashtable with the list items as keys?
d = {key: "some value" for key in your_list} More on reddit.com
๐ŸŒ r/learnpython
7
2
December 24, 2022
๐ŸŒ
Real Python
realpython.com โ€บ iterate-through-dictionary-python
How to Iterate Through a Dictionary in Python โ€“ Real Python
November 23, 2024 - If you use this approach along with the [key] operator, then you can access the values of your dictionary while you loop through the keys: ... In this example, you use key and likes[key] at the same time to access your target dictionaryโ€™s keys and the values, respectively. This technique enables you to perform different operations on both the keys and the values of likes. Even though iterating through a dictionary directly is pretty straightforward in Python, youโ€™ll often find that dictionaries provide more convenient and explicit tools to achieve the same result.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ gloss_python_loop_dictionary_items.asp
Python Loop Through a Dictionary
When looping through a dictionary, the return value are the keys of the dictionary, but there are methods to return the values as well. Print all key names in the dictionary, one by one: ... Python Dictionaries Tutorial Dictionary Access Dictionary Items Change Dictionary Item Check if Dictionary Item Exists Dictionary Length Add Dictionary Item Remove Dictionary Items Copy Dictionary Nested Dictionaries
๐ŸŒ
Python.org
discuss.python.org โ€บ python help
Loops, arrays, dictionaries -- oh my - Python Help - Discussions on Python.org
October 12, 2022 - Is there a way to carry out this set of instructions using a list or dictionary? Or what would your approach be to make the code more efficient? Thx!
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ python โ€บ python_loop_dictionaries.htm
Python - Loop Dictionaries
This view object provides a dynamic ... values. We can loop through dictionaries using the dict.items() method by iterating over the key-value pairs returned by this method....
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ iterate-over-a-dictionary-in-python
Iterate over a dictionary in Python - GeeksforGeeks
July 11, 2025 - ... statesAndCapitals = { 'Gujarat': ... print(key) ... Using `zip()` in Python, you can access the keys of a dictionary by iterating over a tuple of the dictionary's keys and values simultaneously....
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ iterate-through-list-of-dictionaries-in-python
Iterate through list of dictionaries in Python - GeeksforGeeks
November 22, 2021 - To Loop through values in a dictionary you can use built-in methods like values(), items() or even directly iterate over the dictionary to access values with keys.How to Loop Through a Dictionary in PythonThere are multipl
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ iterate-through-list-of-dictionaries-in-python
Iterate Through List of Dictionaries in Python
August 9, 2023 - Iterate through the list of dictionaries using for loop. Now we use the items() method to access the key?value pairs in each dictionary. Print the Key, Value pairs. list_of_dict = [ {"course": "DBMS", "price": 1500}, {"course": "Python", "price": ...
๐ŸŒ
YouTube
youtube.com โ€บ watch
How to Loop Through an Array of Dictionaries in a List in Python - YouTube
A detailed guide on how to successfully loop through a list of dictionaries in Python, addressing common errors and providing solutions for efficient coding....
Published ย  April 2, 2025
Views ย  1
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ python-iterate-over-dictionary-how-to-loop-through-a-dict
Python Iterate Over Dictionary โ€“ How to Loop Through a Dict
March 10, 2023 - The keys() method is compatible with both Python 2 and 3, so it is a good option if you need to write code that works on both versions of Python. In general, using a basic for loop to iterate through the keys of a dictionary is the fastest method of looping through a dictionary in Python.
๐ŸŒ
Reddit
reddit.com โ€บ r/python โ€บ iterate through list of dictionaries and get key and value.
r/Python on Reddit: Iterate through list of dictionaries and get key and value.
May 20, 2016 -

Hello everyone!

I have been unable to get the values out of a list of dictionaries with python. I've tried many things but nothing that is actually useful.

I have:

my_list = [
    { name: 'alex',
       last_name: 'leda'
     }
    { name: 'john',
       last_name: 'parsons'
     }
]

I want to be able to loop through all dictionaries of the list and extract both the key and its corresponding value. Any idea as to how I would be able to accomplish this?

Many thanks!

๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ how can i loop through a list and basically make a dictionary/hashtable with the list items as keys?
r/learnpython on Reddit: How can I loop through a list and basically make a dictionary/hashtable with the list items as keys?
December 24, 2022 -

How can I loop through a list and basically make a dictionary/hashtable with the list items as keys? I was looking at a leetcode solution for finding out which number in a list is a single number. Here's the code :

from collections import defaultdict
class Solution:
    def singleNumber(self, nums: List[int]) -> int:
        hash_table = defaultdict(int)
        for i in nums:
            hash_table[i] += 1
        
        for i in hash_table:
            if hash_table[i] == 1:
                return i

I was wondering if there was an easier way of doing this without using collections and defaultdict

๐ŸŒ
Finance Train
financetrain.com โ€บ loop-python-dictionaries-numpy-arrays
How to loop over python dictionaries and Numpy arrays
June 4, 2022 - In the previous lessons, we learned about how to loop over lists. In this lesson, we will learn about how to loop over python dictionaries and Numpy arrays.
๐ŸŒ
Python Central
pythoncentral.io โ€บ how-to-iterate-through-a-dictionary-in-python
How to Iterate Through a Dictionary in Python | Python Central
November 19, 2024 - Pandas provides several methods to iterate through a dictionary's keys, values, and key-value pairs (items): ... The items() method is the most commonly used approach, as it allows you to access both the keys and values in a single loop.
๐ŸŒ
Team Treehouse
teamtreehouse.com โ€บ community โ€บ how-to-iterate-over-a-list-of-dictionaries-i-know-how-to-iterate-over-items-in-a-dictionary-though
How to iterate over a LIST of dictionaries? I know how to iterate over items in a dictionary though. (Example) | Treehouse Community
March 4, 2017 - The slightly more thought involved portion is what to do with those dictionaries as we handle them. The challenge wants to use the **kwarg functionality to unpack the values from each dictionary into the template string using the keywords in the placeholders. Here is a pretty good write-up on args and kwargs in Python that might help you understand what we're expected to do in the challenge a little better. In our above for-loop we establish where we're sourcing the keywords from to match the string template dict_entity so we give that to our format operation like so
๐ŸŒ
Career Karma
careerkarma.com โ€บ blog โ€บ python โ€บ iterate through dictionary python: step-by-step guide
Iterate Through Dictionary Python: Step-By-Step Guide | Career Karma
December 1, 2023 - The for loop prints out both the ... key-value pair in a dictionary into a tuple. Using a for loop and the items() method you can iterate over all of the keys and values in a list....