0

Hi, can any one help me to explain this test task, because I think I'm missing something

The test task is this: You have been asked to create an inventory management program for a store. Use a dictionary to track all the inventory in the store along with the quantity of each item that the store has. Fill in the code provided to output the number of apples present in the store. Dictionaries can be indexed as lists, using square brackets. I already made a code that achieves the result that the test task wants , but for some reason it doesn't work, if anyone can explain me how to do it the right way or what I'm doing wrong it would help. This is the code that I made and worked: store = {"Orange": 2, "Watermelon": 0, "Apple": 8, "Banana": 42} D = input() if D == "Orange": print (store["Orange"]) elif D == "Watermelon": print (store["Watermelon"]) elif D == "Apple": print (store["Apple"]) elif D == "Banana": print (store["Banana"])

22nd Sep 2021, 1:48 AM
Alan Restrepo
Alan Restrepo - avatar
4 Réponses
+ 2
Hi Anthony! The task says that Fill in the code provided to output the number of apples present in the store. It means only you have to print number of apples and the rest aren't. For that, you don't even have to use input variable and if-elif statements. Simply, print(store["Apple"])
22nd Sep 2021, 2:09 AM
Python Learner
Python Learner - avatar
+ 1
JUMP_LINK__&&__Python__&&__JUMP_LINK Learner thank you so much, for your help, it was something really simple but I didn't see it , do you mind if I ask you in the future for some help again?
22nd Sep 2021, 2:15 AM
Alan Restrepo
Alan Restrepo - avatar
+ 1
Definitely, anytime you want. We all are here to discuss with each other what we learnt. Happy learning!
22nd Sep 2021, 2:27 AM
Python Learner
Python Learner - avatar
+ 1
Thanks again
22nd Sep 2021, 2:29 AM
Alan Restrepo
Alan Restrepo - avatar