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 Machine Learning - Sebastian Raschka
Python Tuple
Python callable()
Python str()
Python Program to Copy a File
Python Program to Add Two Numbers
Python String isdigit()
Python Program to Slice Lists
Python List insert()
Python Set difference_update()
Python id()
Deep Learning with Python - Francois Cholletf
Python Program to Convert Two Lists Into a Dictionary
Python oct()
Python List copy()
Python locals()
Python String partition()
Python strptime()
Building Chatbots with Python Using Natural Language Processing and Machine Learning - Sumit Raj
Python Custom Exceptions
Python __import__()
Python String rsplit()
Python dir()
Python List
Python Program to Print Colored Text to the Terminal
Python time Module
Python Program to Add Two Matrices
Python Program to Create a Countdown Timer
Python pow()
Python Deep Learning - Valentino Zocca & Gianmario Spacagna & Daniel Slater & Peter Roelants
Python issubclass()
Python File I/O Operation