Table of Contents
The clear() method removes all items from the dictionary.
The syntax of clear()
is:
dict.clear()
1. clear() Parameters
clear()
method doesn’t take any parameters.
2. Return Value from clear()
clear()
method doesn’t return any value (returns None
).
3. Example 1: How clear() method works for dictionaries?
d = {1: "one", 2: "two"} d.clear() print('d =', d)
Output
d = {}
Related posts:
Python List
Python String translate()
Python Exception Handling Using try, except and finally statement
Machine Learning with Python for everyone - Mark E.Fenner
Python Machine Learning Cookbook - Practical solutions from preprocessing to Deep Learning - Chris A...
Python bytearray()
Deep Learning with Python - A Hands-on Introduction - Nikhil Ketkar
Python Program to Split a List Into Evenly Sized Chunks
Python Program to Find the Sum of Natural Numbers
Python Program to Safely Create a Nested Directory
Deep Learning with Python - Francois Cholletf
Python vars()
Python Program to Convert String to Datetime
APIs in Node.js vs Python - A Comparison
Python float()
Python *args and **kwargs
Python Strings
Python max()
Python Objects and Classes
Python Set difference_update()
Python Program to Randomly Select an Element From the List
Python bin()
Python Program to Convert Two Lists Into a Dictionary
Python Program to Make a Flattened List from Nested List
Python Function Arguments
Python Program to Convert Decimal to Binary Using Recursion
Python Set update()
Python Dictionary copy()
Python Program to Print all Prime Numbers in an Interval
Python globals()
Python String rindex()
Python Closures