Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
command_respond.py
# coding: utf-8
# A simple command-respond program
# Python asks for input then carries out the specified action base don the condtions of the input
#COMMAND1 = "hello"
#def handle_command(command):
# response = ""
# if command.find(COMMAND1) >= 0:
# response = "huh?"
# return response
comp_name = 'stella'
print("Hi! ask me what my name is.")
user_answer1 = raw_input()
if user_answer1 == 'what is your name?':
print(comp_name)
else:
print("Sorry, I only understand your answer if you type exactly: what is your name?")
print("Try asking what my name is again.")
user_answer2 = raw_input()
if user_answer2 == 'what is your name?':
print(comp_name)
print("Do you want to know my last name?")
user_answer3 = raw_input()
if user_answer3 == 'yes':
print("My last name is luna")
print("So, my full name is " + comp_name + " luna")
#while user_answer1 == 'what is your name?' and user_answer2 == 'what is your name?' and user_answer3 == 'yes':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.