Nested loops


#1

the exercise is asking me to add each element to my “scoops_sold” variable but im not sure how. can someone please help?

exercise:
"Within the sales_data loop, go through each location list and add the element to your scoops_sold variable.

By the end, you should have the sum of every number in the sales_data nested list."

Code so far:

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

scoops_sold = 0
for location in sales_data:
for scoops in location:
print(scoops)


#2

We don’t see any adding going on, here. Where’s the addition?


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.