Mark As Completed Discussion

In this lesson, we will learn about a new type of data structure called dictionaries, with a focus on the following key points,

  1. What are dictionaries and how are they used?
  2. Working with dictionaries in Python.

For the Javascript version of this lesson, please click here.

Previously, we've studied lists and other data types that can only store a single value of an element. Sometimes, you may encounter situations during your program when you need to refer to your data in pairs. In that case, dictionaries are used. They are a data structure in Python that used a technique called hashing to store the data in key-value pairs.

Suppose you want to store information of students in a class, along with information identifiers. In this case, using variables or lists is not recommended as you will have to create too many variables and separating identifiers and their values from the list will be difficult. You will need something that stores and categorizes your data according to the identifiers. Dictionaries are excellent for this purpose as they allow programmers to categorize data into key-value pairs, that is, you can specify multiple values under a single identifier. This makes the problem of storing student information easier!