Level
Find the error
-
# Create a dictionary of fruit prices
-
fruit_prices = {'apple': 0.5, 'banana': 0.3, 'orange': 0.4}
-
print(fruit_prices)
-
# Now, let's add a new fruit to the dictionary
-
fruit_prices{'grape'} = 0.8
-
print(fruit_prices)
-
# Let's update the price of apples
-
fruit_prices['apple'] = 0.6
-
print(fruit_prices)

Dictionary Manipulation in Python

In this exercise, you'll practice manipulating dictionaries in Python. Your task is to identify the line with a syntax error when adding a new key-value pair to the dictionary, and then select the correct implementation. Pay attention to the syntax for accessing and modifying dictionary elements.