python: def traditions_dict(adict):     """     Question 6     Given a dictionary that maps a person to a list of their favorite traditions, return a dictionary with the value being     the list sorted by the last letter of each tradition. If two     traditions have the same last letter, sort by the first letter.     HINT: This will require the use of lambda functions     Args:         adict (dict)     Returns:         dict

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section7.5: Case Studies
Problem 3E
icon
Related questions
Question

python:

def traditions_dict(adict):
    """
    Question 6
    Given a dictionary that maps a person to a list of their favorite traditions, return a dictionary with the value being
    the list sorted by the last letter of each tradition. If two
    traditions have the same last letter, sort by the first letter.

    HINT: This will require the use of lambda functions

    Args:
        adict (dict)
    Returns:
        dict

    >>> traditions_dict({"Jacob": ["The Horse", "Stealing the t", "Midnight Bud"],
                   "Athena": ["Mini Five-Hundred", "Freshman Cake Race", "Buzzweiser Song"],
                   "Liv": ["Freshman Cake Race", "George P. Burdell", "Buzzweiser Song"]})

    {'Jacob': ['Midnight Bud', 'The Horse', 'Stealing the t'],
    'Athena': ['Mini Five-Hundred', 'Freshman Cake Race', 'Buzzweiser Song'],
    'Liv': ['Freshman Cake Race', 'Buzzweiser Song', 'George P. Burdell']}

    >>> traditions_dict({"Madison": ["The Horse", "Midnight Bud", "Buzzweiser Song"],
                   "Anna": ["Mini Five-Hundred", "Buzzweiser Song", "Freshman Cake Race"],
                   "Ashok": ["The Horse", "Freshman Cake Race", "Stealing the t", "Midnight Bud"]})

    {'Madison': ['Midnight Bud', 'The Horse', 'Buzzweiser Song'],
    'Anna': ['Mini Five-Hundred', 'Freshman Cake Race', 'Buzzweiser Song'],
    'Ashok': ['Midnight Bud', 'Freshman Cake Race', 'The Horse', 'Stealing the t']}

# classes_dict = {4232: ["ISYE", "MATH", "HTS"], 2316: ["CS", "CX", "MGT"], 3000: ["ISYE", "MGT", "ECE"], 2027: ["ISYE", "PSYC", "HTS"]}

# print(classes(classes_dict, "ISYE"))

# print(classes(classes_dict, "CS"))

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Lists
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr