Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Python Basics: Dictionaries (Summary)

Dictionaries store data as key-value pairs. They’re not sequences, so you can’t access elements by index. Instead, you access elements by their key. Dictionaries are great for storing relationships or when you need quick access to data. Like lists, dictionaries are mutable.

It’s a good idea to use a dictionary in the following cases:

  • Your data is unordered, or the order doesn’t matter.
  • You’ll need to update or alter the data during the program.
  • The primary purpose of the data structure is looking up values.

To learn more about Python dictionaries, check out:

To test your knowledge, try these quizzes:

This video course is part of the Python Basics series, which accompanies Python Basics: A Practical Introduction to Python 3. Now that you’ve mastered dictionaries, you can check out the other Python Basics courses.


Sample Code (.zip)

1.1 KB

Course Slides (.pdf)

5.8 MB

00:00 Congratulations. You’ve made it to the last lesson of the Python Basics: Dictionaries course. In this course, you learned how to create dictionaries, work with dictionary values, you checked the existence of dictionary keys, and you iterated over dictionaries.

00:17 Finally, you learned how to nest dictionaries.

00:23 Here are a few Real Python resources for you to learn more about dictionaries. The first tutorial, Dictionaries in Python, repeats the basics that you already learned in this video course. On top of that, you’ll learn about dictionary methods that can be super handy when you’re working with dictionaries.

00:40 You already learned some basics about how to loop over dictionaries in this video course, but we only scratched the surface here. In How to Iterate Through a Dictionary in Python, you’ll take a deep dive into how to iterate through a dictionary in Python.

00:55 Like mentioned before, dictionaries are a fundamental data structure, and by iterating through them, you’ll be able to solve a wide variety of programming problems.

01:06 The third tutorial I want to recommend is Sorting a Python Dictionary: Values, Keys, and More. In this tutorial, you’ll get the lowdown on sorting Python dictionaries. By the end, you’ll be able to sort by key, value, or even nested attributes, but you won’t stop there.

01:23 You’ll go on to measure the performance of variations when sorting and compare different key-value data structures. Oh, and we also got quizzes for the Dictionaries in Python and How to Iterate Through a Dictionary in Python tutorials, so if you want to test your understanding on how to use dictionaries, go ahead and take the quizzes. The cool thing is there is no time limit, so you can take your time to answer them.

01:50 And speaking of time, my dog Frieda was patient enough while I was recording this course. So I’ll go out here for now, and I hope that you join us next time again at realpython.com.

Become a Member to join the conversation.