Python Set clear() Method

The set.clear() method removes all the elements from the set.

Syntax:

set.clear()

Parameters:

No parameters.

Return Value:

None.

The following example demonstrates the set.clear() method.

Example: Remove All Elements
langs = {'Python','C++','C','Go'}
langs.clear()
print("Set after the clear() method is called: ", langs)
Output
Set after the clear() method is called:  set()