Python Set clear() Method

Removes all items from the set

Usage

Use clear() method to remove all items from the set.

The method does not return anything; it just updates the set.

Syntax

set.clear()

Basic Example

# Clear the set
S = {'red', 'green', 'blue'}
S.clear()
print(S)
# Prints set()