I'm working on a project for school. I was able to get my function to work the way I need it to, using all of the parameters that the teacher wanted, except when it displays. I need it to pull from two lists, which it does, and display both lists next to each other, which it does. However in the teacher's version, the display/output looks like this:
0. ($2.39) Drip coffee
1. ($3.59) Hot chocolate
2. ($3.79) Caffe Latte
3. ($1.49) Bagel
4. ($2.69) Blueberry muffin
5. ($2.39) Chocolate chip cookie
6. Reset order
7. Checkout
However, my version looks like this:
0 ($2.39) Drip coffee
1 ($3.59) Hot chocolate
2 ($3.79) Caffe Latte
3 ($1.49) Bagel
4 ($2.69) Blueberry muffin
5 ($2.39) Chocolate chip cookie
6. Reset order
7. Checkout
As you can see, I am missing the periods after the index numbers (Sorry if my terminology is not accurate. I am an extreme beginner and I'm having a hard time keeping the terms straight.). Here is my code:
products = [ "Drip coffee",
"Hot chocolate",
"Caffe Latte",
"Bagel",
"Blueberry muffin",
"Chocolate chip cookie" ]
prices = [ 2.39,
3.59,
3.79,
1.49,
2.69,
2.39 ]
for i, product in enumerate(products):
price = prices[i]
print(i, "(${})".format(price), product)
print()
print("6. Reset", "\n" + "7. Checkout")
Is there any way I can add to this or fix it so that the output will display periods in the places I need them? Also, the instructions for the project say to place the options for 6 and 7 as a string outside of the for loop. That's why they are not included like the others. That's also why I was easily able to add the period behind those last two numbers lol. Any help would be appreciated as well as an explanation as to why the solution is what it is. Thanks, everyone!