I have the 2d list mainlist
mainlist = [['John','Doe',True],['Mary','Jane',False],['James','Smith',False]]
slist1 = ['John', 'Doe']
slist2 = ['John', 'Smith']
slist3 = ['Doe', 'John']
slist4 = ['John', True]
How to determine if a sublist of a sublist exists in a list where if slist1 is tested against mainlist will return True while slist2 will return False
I am thinking of something like this (code from here)
for sublist in mainlist:
if all(i in sublist for i in slist1):
return True
break
is there a more "pythonic" way to do this? thanks
edit:
- slist1 tested against mainlist would return True
- slist2 would return False
- slist3 would return False
- slist4 would return False
so basically, i am just testing if slist is in the first 2 index of mainlist[x]