How can I ignore the \"not in list\" error message if I call a.remove(x) when x is not present in list a?
a.remove(x)
x
a
This is my situation:
As an alternative to ignoring the ValueError
ValueError
try: a.remove(10) except ValueError: pass # do nothing!
I think the following is a little more straightforward and readable:
if 10 in a: a.remove(10)