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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started