write about the following dictionaries methods with an example clear() and pop()
Answers
Answered by
1
In Python dictionary, del keyword is used to delete a particular element. The clear( ) function is used to delete all the elements in a dictionary. To remove the dictionary, we can use del keyword with dictionary name. Dict={‘Roll No’: 12001, ‘SName’: ‘Meena’ , ‘Mark1’: 98, ‘Mar12’: 86} print(“Dictionary elements before deletion: \n” , Dict) del Dict[‘Mark1’] # Deleting a particular element Dict.clear( ) # Deleting all elementsRead more on Sarthaks.com - https://www.sarthaks.com/1017879/explain-the-difference-between-del-and-clear-in-dictionary-with-an-example.
please mark me brain mark list
Similar questions