Delete an Element From a Dictionary in Python Using Del Statement
(Last Updated On: 14/03/2023)
Python Program to Delete an Element From a Dictionary Using Del Statement
# Delete an Element From a Dictionary using the del in python
# Initializing dictionary
test_dict = {"Manoj": 22, "Vishal": 21, "Prafull": 21, "Sagar": 21}
print(test_dict)
# empty the dictionary d
del test_dict
try:
print(test_dict)
except:
print('Deleted!')