Python‎ > ‎set‎ > ‎

set.remove()


Definition
Remove an element from a set; it must be a member.

Syntax
set.remove(x)

Parameters
x=element of set

Example
The output is:
 set1={5,6,7,8,9}
>>> set1.remove(7)
>>> set1

>>> 
{8, 9, 5, 6}
>>>


set.remove()
The remove the item from the set.
 >>> from decimal import Decimal
>>> a=set()
>>> a.add(Decimal(1).adjusted())
>>> a.add(Decimal(.55).canonical())
>>> a.add(Decimal(-1).compare_signal(1))
>>> a
{0, Decimal('0.5500000000000000444089209850062616169452667236328125'), Decimal('-1')}
>>> b=set()
>>> b.add(Decimal(1).compare_total(2))
>>> b.add(Decimal(0.1).copy_abs())
>>> b
{Decimal('0.1000000000000000055511151231257827021181583404541015625'), Decimal('-1')}
>>> a.remove(Decimal(-1).compare_signal(1))
>>> a
{Decimal('0.1000000000000000055511151231257827021181583404541015625')}


Comments