Which of the following methods removes all elements from a set in Python?
-
A
remove()
-
B
clear()
Correct answer
-
C
pop()
-
D
discard()
Correct answer
B. clear()
18 views
Explanation
The clear() method removes all elements from a set.
Doubts & discussion
Not sure why the answer is B? Ask here and get an explanation.
Ask a doubt about this MCQ