Write the function greeting that takes a string as input. That string will be formatted as Name Age Hobby, without any punctuation. greeting should split their response into list elements, then use index values to greet them by name and respond that you enjoy that hobby as well, with the format: ‘Hello, ! I also enjoy !' Make sure your output matches this format! For example, greeting('Jose 17 hockey') # => 'Hello, Jose! I also enjoy hockey!' greeting('Cindy 14 robotics') # => 'Hello, Cindy! I also enjoy robotics!'

Respuesta :

Answer:

The function in Python is as follows:

def greetings(details):

   details = details.split(' ')

   print('Hello, '+details[0]+'!, I also enjoy '+details[2])

Explanation:

This defines the function

def greetings(details):

This splits the input string by space

   details = details.split(' ')

This prints the required output

   print('Hello, '+details[0]+'!, I also enjoy '+details[2])

After splitting, the string at index 0 represents the name while the string at index 2 represents the hobby

ACCESS MORE