I want to remove a value from a list if it exists in the list (which it may not).
a = [1, 2, 3, 4] b = a.index(6) del a[b] print(a)
The abov
In one line:
a.remove('b') if 'b' in a else None
sometimes it usefull.
Even easier:
if 'b' in a: a.remove('b')