subject

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))

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 17:30
Which tab should you open to find the option for adding a header?
Answers: 1
question
Computers and Technology, 23.06.2019 11:30
Me dangers of social media and the internetexplain what each means: 1) social media and phones have become an addiction.2) outside people have access to you all the time.3) cyberstalking4) cyberbullying5) catphishing6) viruses7) identity theft8) credit card fraud9) hacking10) money schemes
Answers: 1
question
Computers and Technology, 24.06.2019 00:30
Use the keyword strategy to remember the meaning of the following word. the meaning for the word has been provided. write your keyword and describe the picture you would create in your mind. obfuscate: to make something so confusing that it is difficult to understand.
Answers: 2
question
Computers and Technology, 24.06.2019 08:30
Aconsumer would pay an extra they used the rent to own program to buy the computer, rather than using cash. for all of the items, is the cheapest option over the life of the contract. the most expensive overall option is to use purchase the item.
Answers: 2
You know the right answer?
Given a variable that contains mixed collection types, update the provided function to display the f...
Questions
question
English, 15.12.2021 17:00
question
English, 15.12.2021 17:00
question
Mathematics, 15.12.2021 17:00
question
Mathematics, 15.12.2021 17:00
Questions on the website: 13722362