How can i test if multiple strings exist in another list? Below is a code example that I started with but doesn't work properly. It should return true if even part of the string is found in the list.
I marked in the comments what the result should return. as you can see they all fail though.
def all_exist(avalue, bvalue):
if avalue == []:
return True
else:
print (all(x in avalue for x in bvalue))
items = ['greg','krista','marie']
all_exist(['greg', 'krista'], items) # true
all_exist(['gre', 'kris'], items) # true
all_exist(['gre', 'purple'], items) # false
Would it be better to convert the second list to a single string and then just test if strings in list exist in it?