Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python set remove

s = {0, 1, 2}
s.discard(0)  
print(s)
{1, 2}

# discard() does not throw an exception if element not found
s.discard(0)

# remove() will throw
s.remove(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 0
 
PREVIOUS NEXT
Tagged: #python #set #remove
ADD COMMENT
Topic
Name
8+8 =