Home >>Python Set Methods >Python Set remove() Method
Python Set remove() Method in python set is used to remove the specified element from the given set. This method will raise an error if element does not exist in the set.
Syntax:set.remove(item)
Parameter | Description |
---|---|
item | It is Required. The specified item to be removed. |
lang = {"php", "python", "java"}
lang.remove("python")
print(lang)
def Remove(colors):
colors.remove("red")
print (colors)
colors = set(["blue", "red", "green", "yellow", "orange"])
Remove(colors)