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 Generate a Random Number
Python Decorators
Python Program to Safely Create a Nested Directory
Python String islower()
Python Dictionary popitem()
Python Program to Solve Quadratic Equation
Python Program to Get File Creation and Modification Date
Python Function Arguments
Python object()
Python compile()
Python Program to Get the Full Path of the Current Working Directory
Python String endswith()
Python complex()
Python input()
Python Program to Find the Factors of a Number
Intelligent Projects Using Python - Santanu Pattanayak
Python for Programmers with introductory AI case studies - Paul Deitel & Harvey Deitel
Python Operators
Python Tuple
Python String rindex()
Python Program to Split a List Into Evenly Sized Chunks
Python bytearray()
Deep Learning in Python - LazyProgrammer
Python ascii()
Machine Learning Mastery with Python - Understand your data, create accurate models and work project...
Python Program to Find the Square Root
Python timestamp to datetime and vice-versa
Python String format()
Python Program to Sort Words in Alphabetic Order
Python hash()
Machine Learning with Python for everyone - Mark E.Fenner
Python Program to Catch Multiple Exceptions in One Line