Python - Remove Set Items
پرش به ناوبری
پرش به جستجو
محتویات
Remove Item
To remove an item in a set, use the remove()
, or the discard()
method.[۱]
Note: If the item to remove does not exist,
remove()
will raise an error.
Note: If the item to remove does not exist,
discard()
will NOT raise an error.You can also use the pop()
method to remove an item, but this method will remove the last item. Remember that sets are unordered, so you will not know what item that gets removed.
The return value of the pop()
method is the removed item.
Note: Sets are unordered, so when using the
pop()
method, you do not know which item that gets removed.
منابع آموزشی