Iterating Over Dictionaries in Python


Use .items(), .keys(), and .values() to iterate over dictionaries.

Source Code

my_dict = {"name": "John", "age": 30}
for key, value in my_dict.items():
    print(key, value)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments