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 Program to Find the Largest Among Three Numbers
Python reversed()
Python Set difference_update()
Deep Learning with Python - A Hands-on Introduction - Nikhil Ketkar
Python staticmethod()
Python Program to Catch Multiple Exceptions in One Line
Python String ljust()
Python bool()
Python map()
Python Program to Return Multiple Values From a Function
Python Program to Shuffle Deck of Cards
Python Get Current time
Python Program to Find Sum of Natural Numbers Using Recursion
Python String rfind()
Python float()
Python Artificial Intelligence Project for Beginners - Joshua Eckroth
Python String isdecimal()
Python complex()
Python String casefold()
Python List insert()
Python List pop()
Python bytes()
Python Data Structures and Algorithms - Benjamin Baka
Python del Statement
Python hex()
Python String isspace()
Python enumerate()
Python abs()
Python String rpartition()
Python Anonymous / Lambda Function
Python Matrices and NumPy Arrays
Python range()