Summing specific values within an array in python[Solved]
Question: I am trying to do operations with values that I have added into an array.

step 1:

Loaded a xls file with xlrd library and created an array.
<http://i.imgur.com/Ig6Lz3L.png>

Here is the code.

    
    
    import xlrd
    
    datafile = "data.xls"
    workbook = xlrd.open_workbook(datafile)
    sheet = workbook.sheet_by_index(0)
    
    data = [[sheet.cell_value(r, col) 
                for col in range(sheet.ncols)] 
                    for r in range(sheet.nrows)]
    

I would like to sum all the values within a column `print (data[1][1]) print
(data[2][1]) print (data[3][1]) print (data[4][1]) print (data[5][1])`

summ all the way to I (data[I][1]) ??

like summing all the rows for the same column,

i have tried to do sum data[1] but this sums all the values for the same row
(like an horizontal sum of the values...) and I am trying to do a vertical
sum)


Answer: 
    >>> data = [[1,2],[3,4],[5,6]]
    >>> sum(data[i][1] for i in range(len(data)))
    12 # 2 + 4 + 6
    >>> 
    

