-3

I need to compute the mass of a series of objects in a list

for element in list:
    weight = "a calculation here"

How do I save the weight calculation and add it up for each time it goes through the for loop?

  • Don't call your list `list`. – TDG May 21 '22 at 03:24
  • Does this answer your question? [Summing elements in a list](https://stackoverflow.com/questions/11344827/summing-elements-in-a-list) – TDG May 21 '22 at 03:26

1 Answers1

1
for element in list:
    weight += "a calculation here"

Does this work for you?