Chapters
Python114 chapters

ReferenceSet methods

set.discard()

Removes an item if present, and does nothing if not.

Signature

collection.discard(item)

Parameters

NameMeans
itemwhat to remove

Returns

None.

Example

Python
tags = {"a", "b"}
tags.discard("a")
tags.discard("missing")
print(sorted(tags))

Output

['b']

See also