Question: these are the keys and values in the dictionary called inventory basketball :('50', 'B0009KMXWY ') candy-bar :('5', 'B00E3K3UX2 ') chair :('100', 'B01N2M6ZTK ') Music-player :('240',
these are the keys and values in the dictionary called inventory
basketball :('50', 'B0009KMXWY ')
candy-bar :('5', 'B00E3K3UX2 ')
chair :('100', 'B01N2M6ZTK ')
Music-player :('240', 'B07SD95QCP ')
pocket-knife :('60', 'B0009VCA0I ')
shampoo :('3', 'B01N97PCBH ')
toilet :('320', 'B07H781NMC')
balance = $100
belongings = {}
This function should take three parameters. the user's balance, the inventory dictionary, the user's belongings, and the name of the item to purchase.
If the item does not exist, return 0 and print a messageItem does not exist.If the cost of the item is greater than the current money in wallet, return 0 and print a messageSorry, you don't have enough money in your wallet.Otherwise, add item to bought_items dictionary if it doesn't exist and add 1. Then return the cost of the item.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
