Dictionaries
Work with key-value pairs for storing data.
Dictionaries is a free Python For Kids lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Python For Kids learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
1
Dictionaries
Welcome to the Data Structures lesson! Today, we'll learn about dictionaries in Python, which allow you to store data in key-value pairs.

2
What are Dictionaries?
Dictionaries are collections of items where each item is stored as a pair of a key and a value. They are useful for organizing data in a way that makes it easy to retrieve information based on a unique key.
- Key: A unique identifier for each item.
- Value: The data associated with a key.
3
Creating a Dictionary
You can create a dictionary by placing items inside curly braces ({}), separated by commas. Each key is separated from its value by a colon (:).
Example:
# Creates a dictionary of student grades
grades = {
"Alice": 85,
"Bob": 92,
"Charlie": 78
}4
Accessing Dictionary Values
You can access the value associated with a specific key by using the key inside square brackets ([]) or the get() method.
Example:
# Accesses the grade of Alice using square brackets
print(grades["Alice"]) # Output: 85
# Accesses the grade of Bob using the get() method
print(grades.get("Bob")) # Output: 92
5
Adding Items to a Dictionary
You can add new key-value pairs to a dictionary by assigning a value to a new key.
Example:
# Adds a new student to the grades dictionary
grades["Diana"] = 88
# Prints the updated dictionary
print(grades) # Output: {'Alice': 85, 'Bob': 92, 'Charlie': 78, 'Diana': 88}
6
Modifying Dictionary Values
Since dictionaries are mutable, you can change the value associated with an existing key.
Example:
# Updates Charlie's grade
grades["Charlie"] = 82
# Prints the updated grade for Charlie
print(grades["Charlie"]) # Output: 82
7
Removing Items from a Dictionary
You can remove items from a dictionary using the del statement or the pop() method.
Example:
# Removes Bob from the grades dictionary using del
del grades["Bob"]
# Removes Diana from the grades dictionary using pop()
grades.pop("Diana")
# Prints the updated dictionary
print(grades) # Output: {'Alice': 85, 'Charlie': 82}
8
Iterating Through a Dictionary
You can loop through a dictionary to access its keys and values using a for loop.
Example:
# Iterates through the dictionary and prints keys and values
for student, grade in grades.items():
print(student + " scored " + str(grade))
# Output:
# Alice scored 85
# Charlie scored 82
9
# Creates a dictionary of fruits and their colors
fruits = {
"apple": "red",
"banana": "yellow",
"grape": "purple"
}
# Updates the color of banana
fruits["banana"] = "green"
# Removes grape from the dictionary
del fruits["grape"]
# Prints the dictionary
print(fruits)
10
Great Job!
You've learned how to use dictionaries to store and manage data in key-value pairs. Dictionaries are powerful tools for organizing information in your Python programs. Keep practicing by creating your own dictionaries and experimenting with their features!

Frequently asked questions
Is the “Dictionaries” lesson free?
Yes — the full text of “Dictionaries” is free to read here on the web, and the Python For Kids course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Python For Kids course, upgrade to CoddyKit PRO.
What will I learn in “Dictionaries”?
Work with key-value pairs for storing data. You practise Python For Kids with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Python For Kids?
No prior experience is required. Python For Kids on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Dictionaries” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Python For Kids lesson?
Yes. Every Python For Kids lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Lists and Tuples
- Dictionaries
- Sets
- Manipulating Data Structures