0
Again with a new question :D
Heeey . can somone help me with this question : Dictionaries Dictionaries can be used to store key:value pairs. You have been asked to create an inventory management program for a store. You use a dictionary to track all of the store's inventory along with how many of each item the store has. store = {"Orange": 2, "Watermelon": 0, "Apple": 8, "Banana": 42} PY Complete the provided code to output the number of apples present in the store. Dictionaries can be indexed just like lists, using square brackets.
4 Answers
+ 1
Use `get()` method to obtain an item value, given a key. See the third slide in this
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2451/
+ 1
# Fore any type of fruit in inventory :)
# Takes fruit as input and returns how many there are in the store.
store = {"Orange": 2, "Watermelon": 0, "Apple": 8, "Banana": 42}
user_input = input("Enter type of fruit: ").capitalize()
if user_input in store:
print("There are", store[user_input], "of them.")
else:
print("This fruit has not been catalogued.")
0
not working but i fix it
0
print(store['Apple'])
or
print(store.get('Apple'))