Method signature
clear()
Method Overview
Removes all elements from the set, which makes the set an empty set.
Example
# Example Python program that removes all the elements of a set
# Create a set with five elements
box = {"Pencil", "Eraser", "Pen", "Highlighter", "Paper clip"}
# Remove all the elememts
box.clear()
# Print the set contents
print(box)
print(len(box))Output
set()
0