In this Python Tutorial, you will learn how to iterate over values in a dictionary using dict.values() method.
Python – Iterate over Dictionary Values
To iterate over Dictionary values in Python, get the dictionary values using dict.values() method and use a for loop on this values object to traverse through each value in the dictionary.
The following code snippet demonstrates how to iterate over values in a Python Dictionary.
</>
Copy
for value in dictionary.values():
#statement(s)
Examples (1)
1. Iterate over dictionary values
In the following example, we have taken a dictionary with three key:value pairs. We will get the values from this dictionary using dict.values() method and use Python For Loop to traverse through each value.
Python Program
</>
Copy
dictionary = {'a': 58, 'b': 61, 'c': 39}
for value in dictionary.values():
print(value)
Output
58
61
39
Conclusion
In this Python Tutorial, we learned how to iterate over dictionary values in Python with example.