Python Set clear() Method

❮ Set Methods


Example

Remove all elements from the fruits set:

fruits = {"apple", "banana", "cherry"}

fruits.clear()

print(fruits)
Try it Yourself »

Definition and Usage

The clear() method removes all elements in a set.


Syntax

set.clear()

Parameter Values

No parameters


❮ Set Methods

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.