I want to write a code that can search for specific key words in the user input. I have found areas of this where you set a variable to these keywords and it finds where one of them is and if one of them is it prints a function.
hi = ['hi', 'hello', 'Hi', 'Hello', 'sup', 'Sup', 'howdy', 'Howdy', 'hey', 'Hey']
bye = ['bye', 'Bye', 'Goodbye', 'goodbye', 'Power Down', 'power down', 'Power Off', 'power off']
shut_down = 0
while shut_down < 1:
user_input = input("Input: ")
for element in user_input:
if element in hi:
import random
greeting = random.sample(['Hello there.', 'Howdy partner', 'It is nice to talk to you.', 'Hi friend.', 'Sup mah human!'], 1)
print (greeting)
elif element in bye and not hi:
import random
farewell = random.sample(['Goodbye friend.', 'Goodbye', 'Farewell', 'See you later', 'Bye bud', 'Thanks for talking with me.'], 1)
print(farewell)
shut_down = int(shut_down) + 1
I am planning on adding more to the key words to allow for even more responses to eventually develop a conversation, but this system doesn't run properly as is, it continues to print input but it doesn't print out the responses or follow through.