Why doesn't my code work?

I’m not sure why the code below doesn’t work:

sales_data = [[12, 17, 22], [2, 10, 3], [5, 12, 13]]

scoops_sold = 0
for sales in sales_data:
for scoops in sales:
scoops_sold += 1

it saying that scoops_sold is 0.

This loop iterates over the location list;

This loop iterates over the sales data;

The above should be adding the data to the result, not 1. We are not incrementing the list, but accumulating it to arrive at a final total. Looking at the numbers it should be somewhere around 96.

Be sure your indentation is correct.

1 Like

Thank you for the explanation

1 Like