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

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -