Question
Please Solve in Python You want to have a list of nicknames for each state, therefore you decided to use a dictionary data structure to
Please Solve in Python
You want to have a list of nicknames for each state, therefore you decided to use a dictionary data structure to store this data. Write a function that takes a list of tuples (the output from the previous question, i.e. a list of (
Notes: You can assume that there aren't duplicate nicknames. You can treat NO STATE PROVIDED as a state name and place that in the dictionary as well.
def dict_of_states(tuples): """ >>> dict_of_states([('AL', 'Cotton State'), ... ('LA', 'Pelican State'), ('LA', 'Creole State'), ... ('AL', 'Yellowhammer State'), ('LA', 'Sugar State'), ... ('MS', 'Magnolia State')]) {'AL': ['Cotton State', 'Yellowhammer State'], \ 'LA': ['Pelican State', 'Creole State', 'Sugar State'], \ 'MS': ['Magnolia State']}
>>> dict_of_states([('MO', 'Show Me State'), ... ('NY', 'Empire State'), ('NO STATE PROVIDED', 'Lone Star State')]) {'MO': ['Show Me State'], 'NY': ['Empire State'], \ 'NO STATE PROVIDED': ['Lone Star State']} >>> dict_of_states([('NO STATE PROVIDED', 'Granite State'), \ ('NO STATE PROVIDED', 'Sooner State')]) {'NO STATE PROVIDED': ['Granite State', 'Sooner State']} """
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