I have what is more or less a general question. I’ve been reading about the .remove() and .discard() methods for sets. I know that .remove() will throw a KeyError if the element isn’t present in a set and that .discard() won’t, but in my search, I haven’t been able to find a lot of information about why I would use one over the other.
So I was hoping that someone might be able to shed a little light on that for me. Thank you in advance!
To me, the better option is to use .remove() b/c if the element isn’t present, then you get a KeyError, right? Unless someone can convince me otherwise…