Python Dictionary Tutorial – Complete Guide to Python Dictionaries
A Python dictionary is a built-in data structure that stores data as
key-value pairs, giving you fast lookup, insertion and deletion of
information by key instead of by numeric position. This guide is the starting point
for every dictionary tutorial on this site — from basic syntax to methods,
comprehensions, conversions and performance.
Need Help Learning Python?
If you are learning Python and finding programming concepts difficult,
working with an experienced Python tutor can help you progress faster.
One-to-one Python tutoring sessions provide practical coding exercises,
clear explanations and help with assignments, projects and debugging.
Dictionaries are one of Python's most-used data types, appearing constantly in
data analysis, automation, machine learning pipelines, API responses, configuration
files, and JSON handling — anywhere data needs to be labeled and looked up by name
rather than by index.
Dictionary Syntax and a Quick Example
A dictionary is defined with curly braces { }, storing data as
key:value pairs separated by commas. Keys must be unique;
values can be any data type — strings, numbers, lists, or even other dictionaries.
student = {
"name": "Ali",
"age": 22,
"course": "Python Programming"
}
print(student)
print(student["name"]) # access a value by its key
Output
{'name': 'Ali', 'age': 22, 'course': 'Python Programming'}
Ali
Once created, you can update existing values, add new key-value pairs, or delete
entries at any time — dictionaries are fully mutable. For a deeper walkthrough of
syntax and structure, see the
Dictionary Introduction guide below.
Key Properties of Python Dictionaries
Ordered: Since Python 3.7, dictionaries preserve insertion order.
Mutable: Items can be changed, added, or removed after creation.
Unique Keys: Duplicate keys aren't allowed — assigning the same key twice overwrites the earlier value, and only the last one is kept.
You can also build dictionaries with the dict() constructor, count
their items with len(), and create them dynamically with dictionary
comprehension — each covered in full detail in the
Dictionary Basics section below.
This page is the main hub for every Python dictionary tutorial on
this site. Use the sections and tables below to jump straight to the topic,
method, or operation you need.