Advertisement
Guest User

Sum Cols

a guest
Jan 18th, 2020
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. L = [[1,1,1,1,1,1,1],
  2.      [2,4,4,2,1,2,4],
  3.      [1,1,1,1,1,1,1],
  4.      [1,1,1,1,1,1,1],
  5.      [1,1,1,1,1,1,1],
  6.      [1,1,1,1,1,1,1]]
  7.  
  8. def sum_cols(L):
  9.     horz_lng = len(L[0])
  10.     vert_lng = len(L)
  11.  
  12.     col = 0
  13.     sums = []
  14.  
  15.     for y in range(horz_lng):
  16.         col = 0
  17.         for x in range(vert_lng):
  18.             col += L[x][y]
  19.         sums.append(col)
  20.     return sums
  21.  
  22. print(sum_cols(L))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement