Join our newsletter for the latest updates.
Python Dictionary clear()

Python Dictionary clear()

The clear() method removes all items from the dictionary.

The syntax of clear() is:


clear() Parameters

clear() method doesn't take any parameters.

Return Value from clear()

clear() method doesn't return any value (returns None).

Example 1: How clear() method works for dictionaries?

d = {1: "one", 2: "two"}

print('d =', d)


d = {}