Python Set clear method with Example – Python Tutorial
6 years ago Lalit Bhagtani 0
In this tutorial, we will learn about python set clear method.
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 :-
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.