How can you remove all items from a Python set?
- set.clear()
- set.delete_all()
- set.discard_all()
- set.remove_all()
To remove all items from a Python set, you can use the clear() method. This method clears all elements from the set, leaving it empty. The other options do not exist as methods for removing all items from a set.
Loading...
Related Quiz
- Which method in Scikit-learn would you use to tune hyperparameters of a model?
- The ____ module in Python provides a way to measure the approximate CPU time used by a process.
- To define a generator, you use the ____ keyword in the function definition.
- The ____ method in the unittest framework is used to compare whether two values are equal.
- What keyword is used to catch exceptions in Python?