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 Check If a List is Empty
Python String islower()
Python strptime()
Machine Learning Applications Using Python - Cases studies form Healthcare, Retail, and Finance - Pu...
Python del Statement
Python List clear()
Python Deep Learning Cookbook - Indra den Bakker
Python Artificial Intelligence Project for Beginners - Joshua Eckroth
Python Program to Iterate Over Dictionaries Using for Loop
Python String isprintable()
Python Program to Concatenate Two Lists
Python setattr()
Python Program to Check the File Size
Python type()
Python Program to Transpose a Matrix
Python Set intersection()
Python object()
Python Program to Differentiate Between del, remove, and pop on a List
Python ord()
Python Program to Solve Quadratic Equation
Python isinstance()
Python Program to Generate a Random Number
Python bool()
Python Set update()
Python Program to Measure the Elapsed Time in Python
Python Program to Print Hello world!
Python Set issubset()
Python Anonymous / Lambda Function
Python Dictionary pop()
Python help()
Python List
Python bytes()