How can I test if one of the multiple items exist in a list using or?
I tried:
data = [[1,'a',4,],['a','b','c'],['c',3,5]...]
for i,val enumerate(data):
if 'a' or 'b' or 'c' in val:
data.pop(i)
But it removes the first row only
How can I test if one of the multiple items exist in a list using or?
I tried:
data = [[1,'a',4,],['a','b','c'],['c',3,5]...]
for i,val enumerate(data):
if 'a' or 'b' or 'c' in val:
data.pop(i)
But it removes the first row only
You must test the conditions one at a time:
if 'a' in val or 'b' in val or 'c' in val:
Alternatively, you create two lists, convert them to sets, and test if the first list is a subset of another list. See Python - verifying if one list is a subset of the other for more details.