(Newbie question) I want to write a Python program that removes a concrete item from a set if it is present in the set.
When the set is predefined, the code goes like this:
set = {1,2,3,4,4,5,6,10}
set.discard(4)
print(set)
What would be a way to write this, so that it applies to any set of values not known beforehand? I tried the following but it didn´t work. Is there a method along those lines that does?
def set(items):
if i in items == 4:
set.discard(4)
else:
print("The number 4 is not in the set.")
print(set({1,2,4,6}))