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 max()
Python abs()
Python Program to Convert String to Datetime
Python ascii()
Python String lower()
Python Program to Multiply Two Matrices
Python Program to Convert Decimal to Binary, Octal and Hexadecimal
Python Iterators
Python callable()
Python Program to Create Pyramid Patterns
Python List index()
Deep Learning with Python - Francois Chollet
Machine Learning Applications Using Python - Cases studies form Healthcare, Retail, and Finance - Pu...
Python Program to Create a Countdown Timer
Python Program to Add Two Numbers
Python Operator Overloading
Learning scikit-learn Machine Learning in Python - Raul Garreta & Guillermo Moncecchi
Python Program to Check Whether a String is Palindrome or Not
Python Program to Get the Class Name of an Instance
Python Program to Concatenate Two Lists
Python String isupper()
Python @property decorator
Python Program to Compute the Power of a Number
Python Type Conversion and Type Casting
Python Strings
Python hasattr()
Python Program to Add Two Matrices
Python String split()
Python String strip()
Python repr()
Python bytes()
Python Set copy()