My example is pretty simple, but still: a have a set called basket with n elements (we enter n and then the elements). And what I want is to remove all elements with 'apple' in them. However there can be cases where there is no 'apple' in the set at all and that's when it bugs. When there is 'apple' it's ok.
n = int(input("n= "))
basket = set()
print(f"{n} elements: ")
for i in range(n):
e = input(f"element {i+1}: ")
basket.add(e)
print(basket)
basket.remove('apple')
print(basket)
I expected to be ok even when there is no 'apple' in the set, but it gives error.