Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python Set clear() Method

Python Set clear() Method

Python3 Lists Python Sets


Description

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

Syntax

clear() method syntax:


set.clear()

Parameters

Return Value

none.

Example

Remove all elements from the fruits set:

Example 1

fruits

= {

"

apple

"

,

"

banana

"

,

"

cherry

"

}

fruits

.

clear

(

)

print

(

fruits

)

The output is:


set()

Python3 Lists Python Sets