Nested Lists Codecademy bug?

I’ve been stuck on this part of the lesson all morning, I’ve scoured the forums and my code looks correct but I’m still getting a wrong answer?!

  • My code outputs the correct sum
  • The helper text is asking if my print() method is unindented, which it is.

I don’t know what I’m doing wrong since I am getting the correct output of my code and following all steps correctly.

sales_data = [[12, 17, 22], [2, 10, 3], [5, 12, 13]] scoops_sold = 0 for location in sales_data: for scoops in location: scoops_sold += scoops print(scoops_sold)

You removed a line of code you had to satisfy step 2. That is why it is saying your output looks incorrect.

1 Like

A link to the exercise would be helpful. It may be as @ktsotras pointed out, but it might also be that you are printing the value outside of both loops rather than outside the nested loop only as the instruction states.

Thanks, that worked. I usually remove print functions after I’ve moved onto a new section of the lesson (keeps my output tidy). I haven’t had an issue in the past but I guess I just need to explicitly follow the entire lesson regardless if the old functions are irrelevant.

The instruction says to place the print function outside of the nested loops. It was as @ktsotras mentioned, that I need to keep the old print function in the code as well to be considered “correct”.

1 Like