This method of a set is used to remove all the elements of the set and returns an empty set. Also, note that this method does not delete the set it only removes the set item.
This method does not take any argument, a passing argument will throw an error.
- A set is taken with some values
- We applied clear() method
- Printed the set
- An empty set is being returned
- What is the difference between the clear() method of the list and the clear() method of the set?
They both delete the entire set or list items and returns an empty list or set, so technically there is no difference.