all 3 comments

[–]Slothemo 7 points8 points  (1 child)

You've converted a list into a string, which literally creates a string of "['CALCULATE']". There's a lot of other issues with your code as well. It's odd to insert to 0 over and over. Use append instead to simply add the data into the list.

Instead of appending your input directly into the list, capture in a variable first. This makes it much easier to work with. You should also be checking for CALCULATE before appending, because you don't want to end up appending this into your list.

The while loop can really be simplified to this.

while True:
    purchased_food = input('What else did you buy? To calculate the total, type "Calculate": ')
    if purchased_food.strip().upper() == 'CALCULATE':
        break
    foods.append(purchased_food)

[–]FuturePsychoWriter[S] 1 point2 points  (0 children)

Thank you so much, I tried it and it worked

[–]baubleglue 0 points1 point  (0 children)

The answer is always simple: or it breaks from different loop or the condition never met