Question
Language: Python Topic: Dictionaries Function name: catch_flight Parameters: dictionary, tuple containing two strings Returns: dictionary Description: Youve been stuck in NYC for around 8 months
Language: Python
Topic: Dictionaries
Function name: catch_flight Parameters: dictionary, tuple containing two strings
Returns: dictionary
Description: Youve been stuck in NYC for around 8 months all by yourself because you havent been able to find a good time to fly home. Youre willing to go to any city but want to see how many flights to each location fit your budget. Youre given a dictionary that has city names (strings) as the keys and a list of prices (list) and a tuple containing the range of prices (strings) that you are looking for (inclusive). Create a dictionary that has each city name (string) as a key with a value of the number of flight prices (int) that fall within your price range.
>>> cities = {'Atlanta': ['$7.31', '$8.46', '$24.03', '$12.00', '$8.30'], 'Orlando': ['$6.36', '$9.43', '$15.04', '$19.00'], 'Phoenix': ['$1.01', '$3.18', '$4.30', '$18.01']} >>> prices = ('$8.30', '$17.00') >>> print(catch_flight(cities, prices))
{'Atlanta': 3, 'Orlando': 2, 'Phoenix': 0}
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