Ask coding questions

← Back to all posts
shopping list

I'm trying to make this shopping list for school, basically, 1st section: the customer needs to enter their details and they will get what fruits are available to buy 2nd section: they then need to enter what fruits, the amount, and the cost. Then it should calculate and give them a total. But the code is not starting from the beginning, it's starting from the section where the customer enters what fruits, the amount, and the cost. how do i fix this?

one more question, for the second section, if i want to automatically calculate how much the total cost is for the customer from the price list, how do i do that instead of them having to enter the cost themselves?

here is the code:


Change the filename to
And you can add dictionary. The syntax is:items = {"apples":5,"oranges":10} if you do items["apples"] then it returns 5. To find total cost, you can add all the selected items in list item_selected = [] -- creates list. To add item: item_selected.append(whatever user said). Then adding cost part:

And you are done


@alicelinlin just try this.. i can help you too! Just invite me on the repl if younarent able to do. If the above answer is correct, you can mark this as answered so other people will know you no longer need help :)


I see you already fixed the first issue. For the second issue, are you familiar with arrays?