





Please login
Prime

Prepinsta Prime
Video courses for company/skill based Preparation
(Check all courses)
Get Prime Video
Prime

Prepinsta Prime
Purchase mock tests for company/skill building
(Check all mocks)
Get Prime mock
Python Set clear()
Clear() in Python Sets
The clear() method removes all the elements present in a set. Basically it is used to clear the set.
clear() method does not take any parameters.

Syntax :
set1.clear()
Return Type :
The clear() method does not return any value.
#clear() in python set
set1 = {‘P’, ‘Y’, ‘T’, ‘H’, ‘O’, ‘N’ }
print(set1)
#all the values deleted from set
set1.clear()
print(set1)
Output : {'T', 'O', 'H', 'N', 'P', 'Y'} set()
Login/Signup to comment