Newbie to Python.
Got this code from this forum.Tried extending it but it is not working.
Code I am running:
Thanks
Got this code from this forum.Tried extending it but it is not working.
Code I am running:
import random greetings = ['hola', 'hello', 'hi', 'Hi', 'hey!','hey'] question = ['How are you?','How are you doing?'] responses = ['Okay',"I'm fine"] question1 = ['Your name please?','Can I have your name?'] responses1 = ['My name is Steve',"Steve"] question2 = ['Your age please?','Can I have your age?'] responses2 = ['My age is 24',"24"] while True: userInput = input(">>> ") if userInput in greetings: random_greeting = random.choice(greetings) print(random_greeting) elif userInput in question: random_response = random.choice(responses) print(random_response) elif userInput in question1: random_responses1 = random.choice(responses1) print(random_responses1) elif userInput in question2: random_responses2 = random.choice(responses2) print(random_responses2) else: print("I did not understand what you said")Output:
Output:hola
Hi
How are you doing?
I'm fine
Your name please?
I did not understand what you said <-------- Its not printing --- 'My name is Steve' OR "Steve"
Can I get help.Thanks