my_dict={'a':'Alex','b':'Ronald','c':'Ron'}
my_dict.clear()
print(my_dict)
Output is here
{}
We can check the data type of the output
my_dict={'a':'Alex','b':'Ronald','c':'Ron'}
my_dict.clear()
print(type(my_dict))
Output
<class 'dict'>
my_dict={'a':'Alex','b':'Ronald','c':'Ron'}
del my_dict
print(my_dict) #NameError
The last line will generate error as we can't print the dictionary after deleting the same.
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.