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:
Deep Learning with Python - Francois Chollet
Python String rfind()
Python List insert()
Python Directory and Files Management
Python String endswith()
Python String isspace()
Python Get Current time
Python Exception Handling Using try, except and finally statement
Python Artificial Intelligence Project for Beginners - Joshua Eckroth
Python Program to Create Pyramid Patterns
APIs in Node.js vs Python - A Comparison
Python Iterators
Python staticmethod()
Python int()
Python Dictionary items()
Python String isupper()
Python Program to Randomly Select an Element From the List
Node.js vs Python for Backend Development
Python Program to Find the Largest Among Three Numbers
Python Program to Check Armstrong Number
Python time Module
Learning scikit-learn Machine Learning in Python - Raul Garreta & Guillermo Moncecchi
Python Program to Solve Quadratic Equation
Python Program to Trim Whitespace From a String
Python String center()
Python String index()
Python next()
Python Data Structures and Algorithms - Benjamin Baka
Python String isalpha()
Python String isprintable()
Python super()
Python List copy()