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 Comprehension
Python Set discard()
Python eval()
Python complex()
Python range()
Python Program to Catch Multiple Exceptions in One Line
Python Dictionary popitem()
Python for Loop
Python Program to Solve Quadratic Equation
Python Set intersection()
Python callable()
Python memoryview()
Python next()
Python List insert()
Python Program to Find Hash of File
Deep Learning with Python - A Hands-on Introduction - Nikhil Ketkar
Python Program to Check the File Size
Python String isidentifier()
Python dict()
Python Custom Exceptions
Python timestamp to datetime and vice-versa
Python Program to Safely Create a Nested Directory
Python del Statement
Python Program to Get File Creation and Modification Date
Python Inheritance
Deep Learning from Scratch - Building with Python form First Principles - Seth Weidman
Python Program to Print all Prime Numbers in an Interval
Python Machine Learning Cookbook - Practical solutions from preprocessing to Deep Learning - Chris A...
Python Data Analytics with Pandas, NumPy and Matplotlib - Fabio Nelli
Python object()
Python format()
Python bin()