# Help on Dictionaries

Create a new Python file in this folder called cafe.py .
● Create a list called menu, which should contain at least 4 items in the
cafe.
● Next, create a dictionary called stock, which should contain the stock
● Create another dictionary called price, which should contain the prices for
● Next, calculate the total stock worth in the cafe. You will need to
remember to loop through the appropriate dictionaries and lists to do
this.
● Finally, print out the result of your calculation.

Hello @web2821015562, welcome to the forums! Could you please say where it is that you’re stuck, and any code you have so far?

price = [‘32.55’,‘22.80’,‘15.45’,‘10.20’]
stock_dic = {key:value for key, value in zip(menu,price)}
print(stock_dic)

Try breaking it down into little steps as per the guidance.

So far you have created a dictionary of menu items as the key and prices as the value.

Perhaps reconsider the name `stock_dic` since you used prices rather than stock.

You also used strings for your prices which is fine but since you’re calculating total prices based on stock numbers you would then need to convert it to a float before using it in a calculation.

Next up was adding a dictionary with menu items as keys and the values containing the number of each item currently held in stock. You could do this in the same way as your created your first dictionary containing prices.

Once you have the two dictionaries you need the next step is trying to get the total price of all stock. So get the price per item multiplied by the number of that item in stock (the values of your two dictionaries) for each item in your menu. A loop is suggested.

Once you have a grand total from all these items (either in the loop or out), print it.