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: