user1870662
user1870662

Reputation: 13

How to remove a list that contains certain element from a list

a = [['yes','no'],['riding','0']['riding',1],['yes','no'],['yes','no'],['riding',2]]

needs to remove all the list that contains riding so it would give me

a = [['yes','no'],['yes','no'],['yes','no']]

I have a big list , and the list that contains riding are in no predictable sequence how do i remove them ? thanks everyone

Upvotes: 0

Views: 49

Answers (1)

user1632861
user1632861

Reputation:

Using a simple for loop:

for l in a.copy():
    if "riding" in l:
        a.remove(l)

Upvotes: 1

Related Questions