Python Forum

Full Version: lists
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Trying to see if a name thats in a list is in the text and if possible to get the name with out a defined position of the name in list

example:

names_in_list = ["john", "tim", "jim", "tom"]

text = "Hello john how are you?"

want to check to see if any of the names that are in that list are in the text

then something like if so

the name in the list = x
got it
for item in lst:
    if item in text:
        x = item
        print(item)
    else:
        print(False)