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 String isdigit()
Python datetime
Python Set update()
Python Program to Get the File Name From the File Path
Python Tuple count()
Deep Learning with Python - A Hands-on Introduction - Nikhil Ketkar
Python Program Read a File Line by Line Into a List
Python Program to Multiply Two Matrices
Deep Learning with Python - Francois Cholletf
Machine Learning Mastery with Python - Understand your data, create accurate models and work project...
Python Program to Differentiate Between type() and isinstance()
Python Program to Check the File Size
Deep Learning with Python - Francois Chollet
Python Dictionary setdefault()
Python Set intersection()
Python reversed()
Python Operator Overloading
Python delattr()
Python bytearray()
Python List append()
Python Program to Find LCM
Python Program to Check Prime Number
Python Set difference()
APIs in Node.js vs Python - A Comparison
Python globals()
Python str()
Python sorted()
Python String maketrans()
Python Program to Swap Two Variables
Python Program to Check Armstrong Number
Python String lower()
Python Program to Convert Celsius To Fahrenheit