As stated by numerous other answers, list.remove()
will work, but throw a ValueError
if the item wasn't in the list. With python 3.4+, there's an interesting approach to handling this, using the suppress contextmanager:
from contextlib import suppress
with suppress(ValueError):
a.remove('b')