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
If you have more than one nested level this could help
def nested_remove(L, x):
if x in L:
L.remove(x)
else:
for element in L:
if type(element) is list:
nested_remove(element, x)
>>> m=[[34,345,232],[23,343,342]]
>>> nested_remove(m, 345)
>>> m
[[34, 232], [23, 343, 342]]
>>> m=[[34,[345,56,78],232],[23,343,342]]
>>> nested_remove(m, 345)
>>> m
[[34, [56, 78], 232], [23, 343, 342]]