Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
lists
#1
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
Reply
#2
got it
for item in lst:
    if item in text:
        x = item
        print(item)
    else:
        print(False)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Split dict of lists into smaller dicts of lists. pcs3rd 3 2,360 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  sort lists of lists with multiple criteria: similar values need to be treated equal stillsen 2 3,252 Mar-20-2019, 08:01 PM
Last Post: stillsen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020