Python set discard() method
Remove an item if it is there; no error if it is not.
Syntax
set.discard(item)
Parameters
| item | the value to remove |
Return value
None
Example
Code
s = {1, 2, 3} s.discard(2) s.discard(99) # no error print(s)
Output
{1, 3}
Related
Learn it step by step in the free lesson Dictionaries & Sets, with exercises that check your answers.