import re ## This is a comment! ## A line starting with a hash symbol, will be ignored by the Python interpreter. ## That is, you can use # to insert comments into your program. ## This program also uses a second form of commenting: right after the header line ## of a function definition, you can included comments by putting them in between ## triple quotes. def print_greeting(): """ The purpose of this function is to print out a greeting, which should probably also tell the user a little bit about what kind of input is required. For example, \"Hello. What is your problem.\" or \"Hello. Tell me about your favorite movie.\" This function does not have any parameters and does not have a return value. """ ## YOU HAVE TO COMPLETE THIS FUNCTION. ADD YOUR CODE HERE. def process_input(user): """ This function takes the input string read from the user as parameter. Its purpose is to check for patterns in this input and to then compute the appropriate response for those patterns. This function takes a string (the user input) as its only parameter and it returns a string (the system's response). """ # Convert everything to lower case, so we don't have to worry about case. user = user.lower() ## YOU HAVE TO COMPLETE THIS FUNCTION. ADD YOUR CODE HERE. ## PATTERN MATCHING EXAMPLE: ## m = re.search("you (.+) me",user) ## if m: ## response = "Why do you think I " + m.group(1) + " you." def main(): """ This function contains the main loop which keeps on reading input from the user and outputting responses until the user types bye. """ print_greeting() user = raw_input(">>> ") while user != "bye": response = process_input(user) print response user = raw_input(">>> ") print "Bye, bye. Nice talking to you."