Python Dictionaries Explained for Beginners – Complete Guide with Examples (2026)
\
Python Dictionaries Explained for Beginners: Complete Guide with Examples (2026)
Python Dictionaries Explained for Beginners
Python programming me Dictionary ek powerful data structure hai jo data ko key-value pairs me store karta hai.
Real life me bhi hum dictionary jaisa structure use karte hain.
example:
| Key | Value |
|---|---|
| Name | Rahul |
| Age | 22 |
| City | Mumbai |
Python dictionary bhi isi tarah kaam karta hai.
Example:
student = {
"name": "Rahul",
"age": 22,
"city": "Mumbai"
}
print(student)
Output
{'name': 'Rahul', 'age': 22, 'city': 'Mumbai'}
Dictionary ka use structured data store karne ke liye hota hai.
What is a Python Dictionary?
Python dictionary ek collection of key-value pairs hota hai jisme:
✔ Data curly brackets {} me store hota hai
✔ Har item key : value format me hota hai
✔ Keys unique hoti hain
Example:
car = {
"brand": "Toyota",
"model": "Fortuner",
"year": 2024
}
print(car)
Accessing Values from Dictionary
Dictionary me value access karne ke liye key use hoti hai.
Example:
student = {
"name": "Rahul",
"age": 22
}
print(student["name"])
Output
Rahul
Adding New Items in Dictionary
Dictionary me new key-value pair add karna bahut easy hai.
Example:
student = {
"name": "Rahul",
"age": 22
}
student["city"] = "Delhi"
print(student)
Output
{'name': 'Rahul', 'age': 22, 'city': 'Delhi'}
Updating Dictionary Values
Existing value ko update bhi kar sakte hain.
Example:
student["age"] = 23
Output
{'name': 'Rahul', 'age': 23}
Removing Items from Dictionary
Dictionary se item remove karne ke liye pop() method use hota hai.
Example:
student = {
"name": "Rahul",
"age": 22,
"city": "Delhi"
}
student.pop("age")
print(student)
Output
{'name': 'Rahul', 'city': 'Delhi'}
Loop Through a Dictionary
Dictionary ke items ko loop ke through access kar sakte hain.
Example:
student = {
"name": "Rahul",
"age": 22,
"city": "Delhi"
}
for key in student:
print(key, student[key])
Output
name Rahul
age 22
city Delhi
Important Dictionary Methods
Python dictionaries me kuch useful methods available hote hain.
| Method | Use |
|---|---|
| keys() | All keys return karta hai |
| values() | All values return karta hai |
| items() | Key-value pairs return karta hai |
| pop() | Item remove karta hai |
| update() | Dictionary update karta hai |
Example:
student = {
"name": "Rahul",
"age": 22
}
print(student.keys())
print(student.values())
Nested Dictionaries
Python me dictionary ke andar dictionary bhi ho sakti hai.
Example:
students = {
"student1": {
"name": "Rahul",
"age": 22
},
"student2": {
"name": "Amit",
"age": 24
}
}
print(students)
Ye concept large data structures me bahut useful hota hai.
Dictionary vs List Difference
| Feature | List | Dictionary |
|---|---|---|
| Symbol | [] | {} |
| Access | Index | Key |
| Structure | Single values | Key-value pairs |
Example:
List
fruits = ["apple","banana","mango"]
Dictionary
fruit_price = {
"apple": 120,
"banana": 40
}
Real Life Use of Dictionaries
Python dictionaries ka use real world applications me bahut hota hai.
Examples:
✔ User profiles
✔ API responses
✔ JSON data
✔ Database records
Example:
user = {
"username": "manisha",
"email": "example@gmail.com",
"followers": 1500
}
print(user)
Common Mistakes Beginners Make
Beginners often ye mistakes karte hain:
❌ Duplicate keys use karna
❌ Wrong syntax use karna
❌ Key ko quotes me na likhna
Example of wrong syntax:
student = {name: Rahul}
Correct syntax:
student = {"name": "Rahul"}
Conclusion
Python Dictionaries ek powerful data structure hain jo data ko key-value pairs me organize karte hain.
Python programming me dictionaries ka use:
• User data store karne me
• API responses handle karne me
• Databases aur JSON data manage karne me
Agar aap Python programming beginner hain, to dictionaries ko achhi tarah samajhna bahut important hai.
👉Read Previous Lesson:
1. Python Loops Explained: for Loop and while Loop with Examples for Beginners

Comments