Web Analytics

Python set.discard() Method

Set Method โ€ข Discard

The discard() method removes the specified item from the set.

This method is different from the remove() method, because the remove() method will raise an error if the specified item does not exist, and the discard() method will not.

Syntax

set.discard(value)

Parameters

Parameter Description
value Required. The item to search for, and remove

Return Value

None.

Example

Using the discard() method:

Output
Click Run to execute your code

Related Functions