Menu
Coddy logo textTech

What is a Dictionary?

Part of the Logic & Flow section of Coddy's Python journey — lesson 7 of 78.

A dictionary in Python is a collection of data that stores data in key-value pairs. Unlike lists, which use indices to access elements, dictionaries use keys. Each key in a dictionary must be unique, and it is associated with a value.

Think of a real-world dictionary. You look up a word (the key) to find its meaning (the value).

In Python, a dictionary works similarly. For example, you can have a dictionary where the keys are names of countries and the values are their capitals.

Dictionaries are useful when you have data that is naturally paired together and when you need to quickly access a value by knowing its associated key.

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Logic & Flow