Question: Python: Given a list of fruits, fruit_list , we would like to create a dictionary called prices. The keys in the dictionary are the fruit
Python:
Given a list of fruits, fruit_list, we would like to create a dictionary called prices.
The keys in the dictionary are the fruit names from the list with an 's' added at the end.
The values corresponding to all the entries in the dictionary are 3: the price of all the fruits is 3. Write a dictionary comprehension for the dictionary prices.
Example:
fruit_list = ['banana', 'apple', 'orange', 'pineapple', 'pear', 'plum' ]
prices will be: {'bananas': 3, 'apples': 3, 'oranges': 3, 'pineapples': 3, 'pears': 3, 'plums': 3}
Please note that to get any credit on this question, your answer must be in the form of a dictionary comprehension.
Start with:
prices = {
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
