How to search for particular types of words from a list in a sentence given in the user input?
I found out that by importing re and using re.search I can search for a particular word in a sentence or a whole text. import re user_input = input().lower() if re.search('food', user_input): print ("Are you a foodie?") else: print('cool, bro') In the code below this text I am using the if statement to find if a whole expression is in the list(ex. greetings) import random greeings = ["hello", "hi", "greetings", "sup", "what's up", "hey"] response = ['hey', 'Good morning', "hi", "hi there", "hello"] user_input =input().lower() if user_input in greetings: random_response = random.choice(response) print(random_response) My question is: How can I substitute the word 'food' in the first code so that the program is looking through a whole list of words like the second code's greetings list?