Looking for trustworthy answers? Westonci.ca is the ultimate Q&A platform where experts share their knowledge on various topics. Get detailed and accurate answers to your questions from a community of experts on our comprehensive Q&A platform. Discover in-depth answers to your questions from a wide network of professionals on our user-friendly Q&A platform.

Given a variable that contains mixed collection types, update the provided function to display the first inital and last name of the instructor:

Update the function to accept a list and the name of the instructor you wish to find.
Update the function to reformat the name of the instructor and return it back to the calling program.
If the instructors name is entered as John Smith then the function should return back J. Smith
If the instructors name is entered as Tracy Anne Rios then the function should return back T. Rios
If the instructors name is entered as Jackson then the function should return back Jackson
Add in any exception handling for the following scenarios:
Exceptions related to accessing the list or dictionary should output the message: Instructor not found.
All other exceptions should output the message: An error has occurred.
Test to ensure the program passes the provided test cases found in the TESTS.md file
Hints
You may only use a try/except block, no if statements
Figure out how to use only one return in the method

Tests.md:
Input

Amy Williams
Output

A. Williams
Case 2
Input

Sarah Jane Smith
Output

S. Smith
Case 3
Input

Thomas Tom
Output

Instructor not found.

What i have so far
#!/usr/bin/env python3
# Discussion 10.2: Collection Type Exceptions

# Task 1. Modify Functions for Names
def get_initial_name(initials, name):
list = instructor_name.split(' ') # this function returns a list
try:
initial = list[0][0]
name = list[-1]
f_name = initial + '. ' + name
except:
return 'Instructor not found'

# DO NOT MODIFY BELOW
if __name__ == "__main__":

courses = [
{ "name": "Amy Andrews", "courseName": "Math I", "units": 3 },
{ "name": "Bryan Bravo", "courseName": "English I", "units": 3},
{ "name": "Charles Chavez", "courseName": "Physics I", "units": 3 },
{ "name": "Daniel Diaz", "courseName": "Chemistry I", "units": 3 },
{ "name": "Edgar Allen Elam", "courseName": "Math II", "units": 3 },
{ "name": "Felicia Farr", "courseName": "Music I", "units": 3 },
{ "name": "GarthGarcia", "courseName": "Physical Education I", "units": 3 }
]

# Take Input
instructor_name = input("> ")

# Output the Result
print(get_initial_name(courses, instructor_name))