python array operations: adding the first n elements and stores n-th element of an array to another array

python array operations: adding the first n elements and stores n-th element of an array to another array

Recently encountered a problem when learning data processing, where the share

. 1  DEF array_plus (array_input):
 2      array_input.reverse ()
 . 3  
. 4      plus_plus = [0 for I in Range (len (array_input))]
 . 5      m = 0
 . 6      for I in Range (len (array1)):
 . 7          m + = array_input [I]
 . 8          plus_plus [I] = m
 . 9        #   Print ( 'the current value of m:', m) 
10       #    Print ( 'values for the current plus_plus array:', plus_plus) 
. 11      Print (plus_plus)
 12 is      return plus_plus
 13  
14 
15 if __name__ == '__main__':
16     array = [1,2,3,4,5,6,7,8,9]
17     array_plus(array)

 

Guess you like

Origin www.cnblogs.com/wind-under-the-wing/p/11847333.html
Recommended