if i have an nested list such as:
m=[[34,345,232],[23,343,342]]
if i write m.remove(345) it gives an error message saying elem
There is no shortcut for this. You have to remove the value from every nested list in the container list:
for L in m:
try:
L.remove(345)
except ValueError:
pass
If you want similiar behavior like list.remove, use something like the following:
def remove_nested(L, x):
for S in L:
try:
S.remove(x)
except ValueError:
pass
else:
break # Value was found and removed
else:
raise ValueError("remove_nested(L, x): x not in nested list")