Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions