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
If you know what value to delete, here's a simple way (as simple as I can think of, anyway):
a = [0, 1, 1, 0, 1, 2, 1, 3, 1, 4] while a.count(1) > 0: a.remove(1)
You'll get [0, 0, 2, 3, 4]
[0, 0, 2, 3, 4]