Iterate Over Dictionaries in Python Using Values() Function
(Last Updated On: 28/12/2022)
Python Program to Iterate Over Dictionaries Using Values() Function
# Iterate Over Dictionaries in Python Using Values() Function
# Iterate through all values using .values()
countryAndCode = {
'India': 'IND',
'Afghanistan': 'AFG',
'Canada': 'CAN',
'Russia': 'RUS'
}
print('List Of given Country:\n')
# Iterating over values
# we are using the values() method
for code in countryAndCode.values():
# print all the values present in the dictionary.
print(code)