Question: Python programming. Please provide the code and the resulting output. Question - Given a dictionary that maps a character to a list of professors they

Python programming. Please provide the code and the resulting output.

Question

- Given a dictionary that maps a character to a list of professors they want to talk to, return a dictionary with the value being the list sorted by the last letter in each professors' last name. - If two professors have the same last letter of their last name, sort by the first letter of their first name. - THIS MUST BE DONE IN ONE LINE

Args: prof_dict (dict) Returns: dict

>>> character_dict({"Harry": ["Albus Dumbledore", "Minerva McGonagall", "Severus Snape", "Rubeus Hagrid"], "Hermione": ["Remus Lupin", "Alastor Moody", "Horace Slughorn"]}) {'Harry': ['Rubeus Hagrid', 'Albus Dumbledore', 'Severus Snape', 'Minerva McGonagall'], 'Hermione': ['Horace Slughorn', 'Remus Lupin', 'Alastor Moody']}

>>> character_dict({"Scorpius": ["Severus Snape", "Dolores Umbridge", "Horace Slughorn"], "Neville": ["Cuthbert Binns", "Rubeus Hagrid", "Minerva McGonagall"]}) {'Scorpius': ['Dolores Umbridge', 'Severus Snape', 'Horace Slughorn'], 'Neville': ['Rubeus Hagrid', 'Minerva McGonagall', 'Cuthbert Binns']}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!