Question #724

Which set method will throw an exception if the item to be removed do not exist?

The built-in method remove() removes an element from the set only if the element is present in the set. The discard() will produce the same output but if the element is not present in the set, then a KeyError exception will be thrown. (

Comment on Disqus:

Comment on Twitter:

Question difficulty: πŸ”΅πŸ”΅πŸ”΅πŸ”΅πŸ”΅

Similar questions: