Advertisement
VanoHa

search with any

Feb 15th, 2023
792
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 1 0
  1. name_list = ["Adam", "Dean", "Harvey", "Mick", "John"]
  2. string = "Adam lives in New York"
  3. print("The original list is: " + str(name_list))
  4. print("The original string is: " + string)
  5. result = any(item in string for item in name_list)
  6. print("Does the string contain any name from the list: " + str(result))
  7.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement