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 Armstrong Number
How to get current date and time in Python?
Python Errors and Built-in Exceptions
Python Dictionary copy()
Machine Learning with Python for everyone - Mark E.Fenner
Python round()
Python Program to Get the Full Path of the Current Working Directory
Python String rjust()
Python Set difference()
Python del Statement
Python exec()
Python Program to Check Prime Number
Python Type Conversion and Type Casting
Python getattr()
Python String isalnum()
Deep Learning with Python - Francois Cholletf
Python Program to Count the Occurrence of an Item in a List
Python zip()
Deep Learning from Scratch - Building with Python form First Principles - Seth Weidman
Python datetime
Python setattr()
Python Program to Shuffle Deck of Cards
Python Recursion
Python id()
Python List reverse()
Python Dictionary items()
Python Strings
Python Program to Display the multiplication Table
Python Program to Merge Mails
Python Exception Handling Using try, except and finally statement
Machine Learning Applications Using Python - Cases studies form Healthcare, Retail, and Finance - Pu...
Python String split()