Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given a list of fruits, fruit_list, we would like to create dictionary called pr

ID: 3909522 • Letter: G

Question

Given a list of fruits, fruit_list, we would like to create 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 3.

Write a dictionary comprehension for the dictionary prices.

Ex.:
fruit_list=['banana','apple','orange','pineapple','plum']
prices will be: {'bananas':3, 'apples':3,'oranges':3,'pineapples':3,'plums':3}

Your answer must be in the form of a dictionary comprehension.

Start with:
prices={

Explanation / Answer

fruit_list=['banana','apple','orange','pineapple','plum'] prices = {fruit: 3 for fruit in fruit_list} temp = {} for k,v in prices.items(): temp[k + 's'] = v prices = temp print(prices)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote