You will create a shopping simulation in this activity.
Create a dictionary that stores the prices of items sold in your shop.
Print every item and its price. (Use a for loop)
Ask the user what they want to do in the shop.
If they type the name of a product, print the price of that product.
If they typed something that isn’t in the dictionary, print a message that they can’t buy that item. (use “in” with your if statement)
Create variables to represent money (starting value of your choice) and inventory (blank list). Edit your previous code so that when they type the name of a product, subtract the price from the user’s money and add the item string to the inventory list.
If the user doesn’t have enough funds, do not sell the item.
Add a while loop to allow the user to continue to enter store commands until they decide to quit. Use if/elif/else branches to handle the user’s inputs. Give the user the ability to type any of the following commands:
“help”: shows a list of commands to type
“prices”: lists the items available and their prices
“inventory”: lists the items in the user’s inventory
“quit”: quits the while loop
Bonus feature: write code that allows the user to sell an item from their inventory. This would add the item’s prices to the money variable and removes the item from inventory. If the item is not in the inventory list, print a message indicating that instead.
Bonus prize feature: add code that adds a random item from the store to inventory. Hint: use random.choice() and use list(items) to convert the dictionary to a list of keys. Choose randomly from that list.