Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


The dictionary clear() method is used to delete all key-value pairs present in the dictionary.

Syntax

dictionary.clear()

Parameters

No parameter is required.

Return Value

None.

Example:

In the below example, the clear() method is used to delete all elements of the dictionary called Info.

Info = {
   'name': 'John',
   'age': 25,
   'city': 'London'
}
#delete all elements from 'Info' dictionary.
Info.clear()

print(Info)

The output of the above code will be:

{}

❮ Python Dictionary Methods