'Python: how to determine if a list of sentence exist in a string

Given a list ["one day", "second day"], how to determine if each List exists in a specified string?

string_to_be_searched = "one day i will find you"

It does return the actual sentence found



Solution 1:[1]

Possible solution is the following:

lst = ["one day", "second day"]
string = """one day i will find you"""


for item in lst:
    if item in string:
        print(f"'{item}' IS PRESENT in the string '{string}'")
    else:
        print(f"'{item}' iS MISSING from the string '{string}'")

Prints

'one day' IS PRESENT in the string 'one day i will find you'
'second day' iS MISSING from the string 'one day i will find you'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 gremur