i have a list, for example;the for-in statement is your friend:
3>>L=[]
>>L.append('10')
>>L.append('15')
>>L.append('20')
>>len(L)['10', '15', '20']>>print L
is there a way to sum up all the numbers in a list? the number of
objects in the list is vary, around 50 to 60. all objects are 1 to 3
digit positive numbers.
S = 0
for item in L:
S += int(item)
it can also be used in-line (this is called a "generator expression"):
S = sum(int(v) for v in L)
or even hidden inside a built-in helper function:
S = sum(map(int, L))
</F>