1# Basic syntax:
2del dictionary['key']
3
4# Example usage:
5dictionary = {'a': 3, 'b': 2, 'c': 3, 'd': 4, 'e': 5}
6del dictionary['c'] # Remove the 'c' key:value pair from dictionary
7dictionary
8--> {'a': 3, 'b': 2, 'd': 4, 'e': 5}
1>>> # initialise a dictionary with the keys “city”, “name”, “food”
2>>> person1_information = {'city': 'San Francisco', 'name': 'Sam', "food": "shrimps"}
3
4>>> # delete the key, value pair with the key “food”
5>>> del person1_information["food"]
6
7>>> # print the present personal1_information. Note that the key, value pair “food”: “shrimps” is not there anymore.
8>>> print(person1_information)
9{'city': 'San Francisco', 'name': 'Sam'}
1thisdict = {
2 "brand": "Ford",
3 "model": "Mustang",
4 "year": 1964
5}
6thisdict.pop("model")
1mydict = {'score1': 41, 'score2': 23, 'score3': 45}
2
3del mydict['score2']
4print(mydict)
5{'score1': 41, 'score3': 45}