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 Cookbook - Practical solutions from preprocessing to Deep Learning - Chris A...
Python Program to Slice Lists
Python del Statement
Python RegEx
Python getattr()
Python Exception Handling Using try, except and finally statement
Python Program to Safely Create a Nested Directory
Python Program to Get a Substring of a String
Python Program to Check Leap Year
Python while Loop
Python Program to Count the Number of Each Vowel
Python datetime
Python String rsplit()
Python Closures
Python Set difference()
Python List index()
Python delattr()
Natural Language Processing with Python - Steven Bird & Ewan Klein & Edward Loper
Python chr()
Python input()
Python Program to Split a List Into Evenly Sized Chunks
Applied Text Analysis with Python - Benjamin Benfort & Rebecca Bibro & Tony Ojeda
Python locals()
Python Program to Iterate Over Dictionaries Using for Loop
Python String isnumeric()
Python min()
Deep Learning with Python - Francois Cholletf
Python type()
Python Multiple Inheritance
Python frozenset()
Python Program to Find ASCII Value of Character
Python Get Current time