mycookbook= [["i", "love", "tim", "tam", "and", "chocolate", "ice", "cream"], ["cooking",
"fresh", "vegetables", "is", "easy"], ["fresh", "vegetables", "and", "fruits", "are", "good",
"for", "health"]]
mylist = ["tim tam", "chocolate ice cream", "fresh vegetables and fruits"]
for sentence in mycookbook:
i = 0
while i < len(sentence):
for j in range(i + 1, len(sentence)+1):
phrase = ' '.join(sentence[i:j])
if phrase in mylist:
sentence[i:j] = [phrase]
break
i += 1
print(mycookbook)
bXljb29rYm9vaz0gW1siaSIsICJsb3ZlIiwgInRpbSIsICJ0YW0iLCAiYW5kIiwgImNob2NvbGF0ZSIsICJpY2UiLCAiY3JlYW0iXSwgWyJjb29raW5nIiwgCiJmcmVzaCIsICJ2ZWdldGFibGVzIiwgImlzIiwgImVhc3kiXSwgWyJmcmVzaCIsICJ2ZWdldGFibGVzIiwgImFuZCIsICJmcnVpdHMiLCAiYXJlIiwgImdvb2QiLCAKImZvciIsICJoZWFsdGgiXV0KbXlsaXN0ID0gWyJ0aW0gdGFtIiwgImNob2NvbGF0ZSBpY2UgY3JlYW0iLCAiZnJlc2ggdmVnZXRhYmxlcyBhbmQgZnJ1aXRzIl0KCmZvciBzZW50ZW5jZSBpbiBteWNvb2tib29rOgogICAgaSA9IDAKICAgIHdoaWxlIGkgPCBsZW4oc2VudGVuY2UpOgogICAgICAgIGZvciBqIGluIHJhbmdlKGkgKyAxLCBsZW4oc2VudGVuY2UpKzEpOgogICAgICAgICAgICBwaHJhc2UgPSAnICcuam9pbihzZW50ZW5jZVtpOmpdKQogICAgICAgICAgICBpZiBwaHJhc2UgaW4gbXlsaXN0OgogICAgICAgICAgICAgICAgc2VudGVuY2VbaTpqXSA9IFtwaHJhc2VdCiAgICAgICAgICAgICAgICBicmVhawogICAgICAgIGkgKz0gMQoKcHJpbnQobXljb29rYm9vayk=
[['i', 'love', 'tim tam', 'and', 'chocolate ice cream'], ['cooking', 'fresh', 'vegetables', 'is', 'easy'], ['fresh vegetables and fruits', 'are', 'good', 'for', 'health']]