python - Adding return values of two sum() e.g sum()+sum() and store it new list -
a = map(int, raw_input().split()) n = len(a) in range(0, n): start_sum = sum(a[0:i+1]) # calculate sum of first last_sum = sum(a[-(n-i):]) # calculate sum of last n-i
now have store sum of start_sum , last_sum , store in new list b index same i .like below
b[i] = start_sum + last_sum
how implement this. new python. great.
one solution be:
a = map(int, raw_input().split()) b = [] in range(0, n): start_sum = sum(a[0:i+1]) # calculate sum of first last_sum = sum(a[-(n-i):]) # calculate sum of last n-i b.append(start_sum + last_sum)
other solutions possible... problem had, b had not been created list n places, putting @ place i
fail.
Comments
Post a Comment