Remove a sub list from nested list based on an element in Python
Use list_comprehension
. It just builts a new list by iterating over the sublists where the second element in each sublist won't contain the string done
>>> l = [["a", "done"], ["c", "not done"]]
>>> [subl for subl in l if subl[1] != 'done']
[['c', 'not done']]
>>>
l = [["a", "done"], ["c", "not done"]]
print [i for i in l if i[1]!="done"]
or use filter
l = [["a", "done"], ["c", "not done"]]
print filter(lambda x:x[1]!="done",l)