Copyright © tutorialspoint.com

Python dictionary clear() Method

previous next


Description:

This class method remove all items from the dictionary.

Syntax:

dict.clear()

Example:

#!/usr/bin/python

dict = {'Name': 'Zara', 'Age': 7};

print "Start Len : %d" %  len(dict)
dict.clear()
print "End Len : %d" %  len(dict)

This produces following result:

Start Len : 2
End Len : 0

previous next

Copyright © tutorialspoint.com