set.remove() in python



"remove()" function is used to remove the specified element in the set.




Syntax:




set.remove(set_value)







Example-1
n = {10, 20, 30, 50, 60}

n.remove(50)

print(n)


Output



{10, 20, 60, 30}







Example-2
n = {10, 20, 30, 50, 60}

n.remove(60)

print(n)


Output



{10, 50, 20, 30}







Example-3
n = {"A", "B", "C", "D", "E"}

n.remove("C")

print(n)


Output



{'E', 'D', 'A', 'B'}