Method Name:
clear
Method Signature:
clear()
Return Value:
None
Overview:
The clear() method removes all the items from the dictionary.
Example:
# Example Python program that removes # all the entries from a Python dictionary expiredOrders = {1:"Expired", 10:"Expired", 14:"Expired", 15:"Expired"}; expiredOrders.clear(); print("Length of dictionary after removing all items:"); print(len(expiredOrders)); |
Output:
Length of dictionary after removing all items: 0 |