my_dict = {'a': 1, 'b': 2, 'c': 3}
print("Original dictionary:", my_dict)
my_dict.clear()
print("Dictionary after clearing:", my_dict)
Original dictionary: {'a': 1, 'b': 2, 'c': 3}
Dictionary after clearing: {}
my_dict
` with some key-value pairs. Then we print the original dictionary using the `print()
` function.clear()
` method to remove all key-value pairs from the dictionary. Finally, we print the dictionary after clearing using the `print()
` function.