What is the difference between remove() and discard() on a set in Python?
Correct answer
B. remove() raises KeyError if missing; discard() does not
6 views
B. remove() raises KeyError if missing; discard() does not
6 views
discard() silently ignores missing elements.
Asked in: Python Interview Sets
https://docs.python.org/3/tutorial/datastructures.html#setsNot sure why the answer is B? Ask here and get an explanation.