Given a tuple containing a bunch of integer elements, how can one find the sum of all the elements?
For example, if I have a list of tuples:
li = [(1
For beginner:
for
loop.Demo:
>>> li = [(1, 2), (1, 3), (2, 3)] # Given Input
>>> result = [] # Step 1
>>> for i in li: # Step 2
... tmp_sum = 0 # Step 3
... for j in i: # Step 3
... tmp_sum += j # Step 4
... result.append(tmp_sum) # Step 5
...
>>> print result
[3, 4, 5]