16. Dictionary
What is Dictionary?
employee = {"name" : "Abhi",
"role" : "Trainer",
}
print(employee){'name': 'Abhi', 'role': 'Trainer'}Keys Must be immutable:
Properties of a Dictionary :
Ordered :
Mutable:
Does not allow duplicate Keys:
Functions used in Dictionaries :
How to access values from a dictionary :
How to change values in a dictionary :
How to add values in a Dictionary :
Dictionary Methods :
keys() :
values():
items() :
Iteration in keys of dictionaries:
Iteration in values of dictionaries:
Iteration of key-value pair or items in dictionaries:
How to create dictionary with user inputs:
how to add an iterables items in a dictionaries: update()
Remove items from Dictionary :
pop() method :
popitem() :
setdefault :
clear() :
copy() :
dict():
Assignment:
Last updated