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 00:30
Which of the following methods could be considered a “best practice” in terms of informing respondents how their answers to an on-line survey about personal information will be protected? respondents are informed that investigators will try to keep their participation confidential; however, confidentiality cannot be assured. respondents are informed that a research assistant will transfer all the research data to a password-protected computer that is not connected to the internet, via a usb flashdrive. the computer is located in a research team member’s office. the investigator uses the informed consent process to explain her institution’s method for guaranteeing absolute confidentiality of research data. the investigator uses the informed consent process to explain how respondent data will be transmitted from the website to his encrypted database without ever recording respondents’ ip addresses, but explains that on the internet confidentiality cannot be absolutely guaranteed.
Answers: 1
question
Computers and Technology, 22.06.2019 02:00
Aletter or menu command that starts an action when the user presses the designated letter and the alt key together is called what?
Answers: 1
question
Computers and Technology, 22.06.2019 17:30
How do you make a lenny face? plz, brailiest to who can answer first.
Answers: 1
question
Computers and Technology, 24.06.2019 15:30
What type of forensic evidence was recovered during the bomb set off at the new mexico facility on the video that was similar to the evidence obtained at the boston bombings and how did the evidence allow the researchers to connect other pieces of evidence to the same bomb?
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
Physics, 16.10.2020 18:01
question
Mathematics, 16.10.2020 18:01
question
Social Studies, 16.10.2020 18:01
question
Health, 16.10.2020 18:01
question
Mathematics, 16.10.2020 18:01
question
Chemistry, 16.10.2020 18:01
question
Mathematics, 16.10.2020 18:01
question
Mathematics, 16.10.2020 18:01
Questions on the website: 13722360