$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · medium · #166

Which fix removes the bug?

total = 0
for price in prices:
    total =+ price
  1. Swap =+ for +=
  2. Initialise total to 1
  3. Cast price to int
  4. Move total inside the loop
=+ price parses as = (+price), so each pass overwrites the total instead of adding to it.
Play Problem Solving ▸