Get Dictionary Keys :
x = thisdict.keys()
print(x)
Output :
dict_keys(['brand', 'model', 'year'])
Dictionary Keys Reflect Changes :
car = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
x = car.keys()
print(x)
car["color"] = "white"
print(x)
Output :
dict_keys(['brand', 'model', 'year'])
dict_keys(['brand', 'model', 'year', 'color'])
Get Dictionary Values :
x = thisdict.values()
print(x)
Output :
dict_values(['Ford', 'Mustang', 1964])
Get Dictionary Items (key-value pairs) :
x = thisdict.items()
print(x)
Output :
dict_items([('brand', 'Ford'), ('model', 'Mustang'), ('year', 1964)])
Dictionary Items Reflect Changes :
car = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
x = car.items()
print(x)
car["year"] = 2020
print(x)
Output :
dict_items([('brand', 'Ford'), ('model', 'Mustang'), ('year', 1964)])
dict_items([('brand', 'Ford'), ('model', 'Mustang'), ('year', 2020)])