Python Dictionary clear Function

Python clear function is used to clear or remove total items (key-value pairs) from a Dictionary. The syntax behind this clear function is:


Python Dictionary clear function Example

The clear function removes keys and values in a given dictionary. The code below removes items from the emp.

TIP: Please refer to the Dict article to understand everything about them in Python.

emp = {'name': 'John', 'age': 25 , 'job': 'HR', 'Sal': 725000}

print("Dictionary: ", emp)
print("Dictionary Length: ", len(emp))

print("\nDictionary: ", emp)
print("Dictionary Length: ", len(emp))
Python Dictionary clear function Example

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.