# create a dictionary
my_dict = {"apple": 2, "banana": 3, "orange": 4}
# access an item by key
print(my_dict["apple"])
print(my_dict["orange"])
2
4
get()
` method to access items by key. This method returns `None
` if the key is not found in the dictionary.# create a dictionary
my_dict = {"apple": 2, "banana": 3, "orange": 4}
# access an item by key using get()
print(my_dict.get("apple"))
print(my_dict.get("pear"))
2
None
items()
` method to access all the items in a dictionary.# create a dictionary
my_dict = {"apple": 2, "banana": 3, "orange": 4}
# access all items using items()
for key, value in my_dict.items():
print(key, value)​
apple 2
banana 3
orange 4