Download our e-book of Introduction To Python
Sulochana Kamshetty
3 years ago
>>> empty = {}
>>> empty
{}
My_dict= {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
print(my_dict)
{'brand': 'Ford', 'model': 'Mustang', 'year': 1964}
keys = ['a','b','c','d','e']
values = [1,2,3,4,5]
# but this line shows dictionary comprehension
here
My_Dict = { k:v for (k,v) in zip(keys, values)}
# We can use below too
# my_Dict = dict(zip(keys, values))
print (my_Dict)
{'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}