Function Details: discard

Description


Removes an element from a set if it is a member.


Extended Description


The discard() method removes the specified element from the set if it is present. If the element is not found in the set, no error is raised. This method modifies the set in-place and does not return a value. It's a safer alternative to remove() when you're not sure if the element is in the set.


Function Signature


set.discard(element: Any) -> None

Module: set

Class: set

Parameters



Parameter List


  • element: Any

Return


This method doesn't return a value (None).


Return Type


None

Output

Explanation

This example shows how discard() removes an element if present and does nothing if not present.