Study Guide

8.2.7 Listed Greeting CodeHS Answers

8.2.7 Listed Greeting CodeHS Answers

The most common answer is:

fill in this function to greet the user!
user_info = “Eva 1000 drawing”
def greeting(user_info):
greeting = user_info.split()
return “Hello, ” + (greeting[0]) + “! I also enjoy ” + (greeting[-1]) + “!”
print (greeting(user_info))

Thr function greeting is well set up to split the user_info string into a list and construct a greeting message using the first and last elements of that list.

Just ensure to use standard ASCII quotation marks for compatibility with Python syntax. Here’s the corrected version of code:

user_info = "Eva 1000 drawing"

def greeting(user_info):
    greeting = user_info.split()
    return "Hello, " + greeting[0] + "! I also enjoy " + greeting[-1] + "!"

print(greeting(user_info))