has any simply way to delete a value in list of python
- by zjm1126
a=[1,2,3,4]
b=a.index(6)
del a[b]
print a
it show error:
Traceback (most recent call last):
File "D:\zjm_code\a.py", line 6, in <module>
b=a.index(6)
ValueError: list.index(x): x not in list
so i have to do this :
a=[1,2,3,4]
try:
b=a.index(6)
del a[b]
except:
pass
print a
but this is not simple,has any simply way ?
thanks