Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

How to Iterate Through a Dictionary in Python: Overview

Dictionaries are one of the most important and useful data structures in Python. They can help you solve a wide variety of programming problems. This course will take you on a deep dive into how to iterate through a dictionary in Python.

By the end of this course, you’ll know:

  • What dictionaries are, as well as some of their main features and implementation details
  • How to iterate through a dictionary in Python by using the basic tools the language offers
  • What kind of real-world tasks you can perform by iterating through a dictionary in Python
  • How to use some more advanced techniques and strategies to iterate through a dictionary in Python

For more information on dictionaries, you can check out the following resources:

Ready? Let’s go!


Sample Code (.zip)

4.7 KB


Course Slides (PDF)

89.1 KB

solidgames on Dec. 27, 2019

Keys must be hashes which normally means they have to be “mutable”? Don’t you mean keys are normally “immutable”.

Ajay on Dec. 29, 2019

Keys in dictionary must be immutable.

Liam Pulsifer RP Team on Dec. 29, 2019

Yes indeed @solidgames and @ASK – I misspoke there.

Ajay on Dec. 31, 2019

@Liam It was nice tutorial, learnt some new things.

Liam Pulsifer RP Team on March 18, 2020

If you’re confused at 3:10-3:25 when I say “a totally different list object,” what I meant there was that the contents of the list have changed, not that the id value of the object has changed or that I’ve created a new object. If you’d like more information on how this works, check out this tutorial realpython.com/python-is-identity-vs-equality/

kiran on Aug. 11, 2020

Can you make deep dive into hashable or give any resources for know more about hashables & unhashables in Python.

Bartosz Zaczyński RP Team on Aug. 11, 2020

We have a 3-minutes long explanation of the hashable objects by James: realpython.com/lessons/immutable-vs-hashable/

Become a Member to join the conversation.