Мне интересно, есть ли способ проверить, существует ли какая-либо комбинация из более чем двух элементов из списка в другом списке?
list_1 = ['apple','soap','diet coke','banana','sweets','mash','fruit','veggies']
for string in lists:
strings = string.split()
print(strings)
ВЫБОР ВЫБОРА для строк:
['today', 'i','bought','banana','but','forgot','soap', 'and','veggies']# this line should identify 'banana', 'soap' and 'veggies'
['maybe', 'there','are','more','sweets','left','later'] # this line should be ignored, because not more than 2 items of the list are in it
['food', 'shopping','is','boring','and','i','hate','mash','with','veggies']# this line should identify 'mash' and 'veggies'
Я знаю, что с помощью этого фрагмента кода я могу по крайней мере проверить, присутствует ли какой-либо из элементов в строках:
combinations = any(i in list_1 for i in strings)