Want to learn the smartest way to organize data in Python? Whether you're a student, hobby coder, or just curious, this skill will save you time.
Imagine having a digital schoolbag that stores everything neatly with labels. That’s what dictionaries do in Python.

How to use dictionaries in Python with code is easier than you think, even if you're just starting out. In this guide, we’ll make Python dictionaries so simple that even a 12-year-old can use them confidently. No scary terms. Just a step-by-step path to help you learn faster.
Whether you want to save student marks, store names with roll numbers, or track your own mini projects, dictionaries can do it all. So let’s jump in!
A Python dictionary is like a mini locker with labels on each compartment.
Let’s say you have a school bag with three zipped pockets. One has your name tag, one your age, and one your grade. In Python, that’s:
Copy Code
student = {"name": "Riya", "age": 14, "grade": "A"}Here’s what’s happening:
Copy Code
"name", "age", and "grade" are called keys "Riya", 14, and "A" are their matching values
You can think of a dictionary as a key-value pair container, just like a real notebook that stores information under headings.
Let’s break down how to use dictionaries in Python with code in 5 simple beginner steps.
Making a dictionary is like making your own custom bag of data.
book = {"title": "Harry Potter", "pages": 340}
This one stores a book's title and number of pages.
Analogy: Think of this as labeling drawers in a cupboard. Each drawer (key) holds one type of info (value).
To read data, you ask the dictionary using a key.
print(book["title"]) # Output: Harry Potter
It’s like asking, “What’s the book title?” and Python gives you the value.
Here’s a quick table to understand:
| Key | Value |
| "title" | "Harry Potter" |
| "pages" | 360 |
Want to change your grade or update your pet’s name?
student["grade"] = "A+"
This updates the value for the "grade" key. Simple and clean.
Need to add a new subject score or a hobby?
student["hobby"] = "Reading"
Python adds "hobby": "Reading" to the dictionary, like adding a new page in your notebook.
To remove something, you can use del or pop():
del student["age"]
Or if you want to keep the value while removing:
score = student.pop("grade")
Friendly tip: Use pop() when you need to use the value later.
Let’s get real. Why should you even learn this?
Because dictionaries save time, effort, and stress. Especially in school projects or coding apps.
Here’s where they shine:
Let’s say you’re building a library app. You can use a dictionary to store book titles, authors, and availability. It keeps your data clean and easy to update — no messy lists or confusing indexes.
Unlike lists, dictionaries don’t need numbers to search. Just use the label, and done!
So next time someone says, “Python’s hard,” you can say, “Not when I use dictionaries.”
Python dictionaries come with built-in tools (called methods) to help you work faster. Here are the ones beginners must know:
Use .get() to safely access a value without crashing your code.
Copy Code
student.get("name") # RiyaThis works even if the key doesn't exist; it just returns None.
Want to see all the keys?
Copy Code
student.keys() # dict_keys(['name', 'hobby'])
It shows all the labels (keys) in your dictionary.
Shows all the data (values) inside:
Copy Code
student.values() # dict_values(['Riya', 'Reading'])
Use this when you want to see both key and value:
student.items()
Copy Code
# dict_items([('name', 'Riya'), ('hobby', 'Reading')])Here’s a quick cheat sheet:
| Method | What It Does |
| .get("key") | Safely gets a value |
| .keys() | Lists all the keys |
| .values() | Lists all the values |
| .items() | Lists key-value pairs |
These are the basic tools you'll use again and again.
Once you know how to create and use dictionaries, looping makes them even more powerful.
Let’s say you want to print all the key-value pairs in a dictionary. Here’s a simple way:
for key in student:
print(key, student[key])
This loop goes through each key and prints the value attached to it.
You can also do it using .items():
for key, value in student.items():
print(key, value)
Imagine you're making a quiz app. You want to show all questions and correct answers stored in a dictionary. Loops help you go through everything, one by one, without writing long code.
A nested dictionary means one dictionary inside another. It’s like having folders inside folders, each holding related information. You use nested dictionaries when you want to group data under a larger label, like storing details of many students in one class. This helps you stay organized and manage complex data easily, even in beginner projects.
Think of it as a classroom with student files. Each student file has name, age, and grade, and all files are inside a big folder called class10.
Example:
Copy Code
class10 = {
"student1": {"name": "Riya", "age": 14},
"student2": {"name": "Aman", "age": 13}
}
Want Riya’s age?
class10["student1"]["age"] # Output: 14You’ll use this when storing grouped data, like employees in a company or scores of different players.
Before you start using dictionaries in your code, here are some smart tips to help you avoid mistakes:
A dictionary in Python is a collection of data stored in key-value pairs. You can use dictionaries to store information like names, scores, or any related data. They are flexible, easy to use, and great for beginners. You can add, update, or access data using just a few lines of simple Python code.
Now you know what Python dictionaries are, how to use them, and where to apply them. From school reports to fun mini projects, dictionaries are your smart tool to keep things organized.
This makes your Python projects easier to manage.
And the best part? You didn’t need long, boring code to learn it.
So, what’s next? You can start by creating your own dictionary about your pet, a game you like, or your weekly tasks. If you’re feeling curious, you can even explore how dictionaries work with functions or files in Python.
This is just the beginning. Keep practicing, keep coding, and you will master Python one small step at a time. And if you ever want hands-on help with real-world projects, Uncodemy’s beginner-friendly Python course is a great place to start.
Start learning today and build your Python skills with confidence.
A dictionary is like a label box. Each label (called a key) holds a value. It helps you store and find data easily, like a digital notebook.
Use curly brackets with key-value pairs inside.
Example:
student = {"name": "Riya"}
Yes! You can update any value by using its key.
student["name"] = "Isha"
Depends on the task.
Just remember this format:
{key: value}
Like writing "subject": "Math" or "name": "Amit"
Personalized learning paths with interactive materials and progress tracking for optimal learning experience.
Explore LMSCreate professional, ATS-optimized resumes tailored for tech roles with intelligent suggestions.
Build ResumeDetailed analysis of how your resume performs in Applicant Tracking Systems with actionable insights.
Check ResumeAI analyzes your code for efficiency, best practices, and bugs with instant feedback.
Try Code ReviewPractice coding in 20+ languages with our cloud-based compiler that works on any device.
Start Coding
TRENDING
BESTSELLER
BESTSELLER
TRENDING
HOT
BESTSELLER
HOT
BESTSELLER
BESTSELLER
HOT
POPULAR