I'm trying to built an assistant, at first while I say "hi" it returns "hi" working great.
but if I say "hi, what time is it" it goes to the first if
cause it finds the value "hi" in my sentence.
This is a piece of my code:
def run_alexa():
command = take_command()
matches_hi = ['hey', 'hello', 'hi there']
if any(x in command for x in matches_hi):
talk(random.choice(matches_hi))
print()
if 'what time' in command:
time = datetime.datetime.now().strftime('%H:%M:')
talk('The current time is' + time)`
command is the variable that contains my speech
I'm trying to make the code ignore the first if
(without using elif in that cause cause it will not let me run 'elif any') while I'm saying "hello, what time is it?" or whatever.