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
CodePudding user response:
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'