The clear() method removes all elements from the dictionary.
Example
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
list = ['MIT', 'Stanford','NWU', 2012, 2019]
print("list is: ", list)
list.clear()
print("after clearing ,the list is : ", list)
Output:
list is: ['MIT', 'Stanford', 'NWU', 2012, 2019]
after clearing ,the list is : []
Syntax
list.clear()
Parameters
This method doesn’t take any parameters.
Return Value
The method doesn’t return any values.