Python Set clear method with Example – Python Tutorial

1 month ago Lalit Bhagtani 0

In this tutorial, we will learn about python set clear method.
Python Set Clear

clear method :

This method is used to remove all the elements from the set object.

Syntax : < Set Object >.clear( ) 

Example:

# create set object and assign it to variable s s = {1,2,3,4,5} # print all elements of set print(s) # call clear() method to remove all the elements from s s.clear() # print all elements of set print(s)

References :-

  1. clear method Docs

That’s all for Python Set clear method. If you liked it, please share your thoughts in comments section and share it with others too.

Previous