Python Dictionaries
Create a new dictionary
dict = {
"name" : "John",
"age" : 40,
"department": "Software Engineering"
}
print(dict)Adding a new key value pair
dict = {
"name" : "John",
"age" : 40
}
dict["job title"] = "Lead Engineer"
print(dict)Fetch items using key
fetch item using the .get()
Deleting items from a dictionary using the del keyword
del keywordIterating through a dictionary
Dictionary comprehension
Last updated