About lists in python
Question: I have an excel file with a column in which values are in multiple rows in
this format 25/02/2016. I want to save all this rows of dates in a list. Each
row is a separate value. How do I do this? So far this is my code:

I have an excel file with a column in which values are in multiple rows in
this format 25/02/2016. I want to save all this rows of dates in a list. Each
row is a separate value. How do I do this? So far this is my code:

    
    
    import openpyxl
    wb = openpyxl.load_workbook ('LOTERIAREAL.xlsx')
    sheet = wb.get_active_sheet()
    rowsnum = sheet.get_highest_row()
    wholeNum = []
    for n in range(1, rowsnum):
        wholeNum = sheet.cell(row=n, column=1).value
    
    print (wholeNum[0])
    

When I use the print statement, instead of printing the value of the first row
which should be the first item in the list e.g. 25/02/2016, it is printing the
first character of the row which is the number 2. Apparently it is slicing
thru the date. I want the first row and subsequent rows saved as separate
items in the list. What am I doing wrong? Thanks in advance


Answer: `wholeNum = sheet.cell(row=n, column=1).value` assigns the value of the cell
to the variable wholeNum, so you're never adding anything to the initial empty
list and just overwrite the value each time. When you call `wholeNum[0]` at
the end, wholeNum is a the last string that was read, and you're getting the
first character of it.

You probable want `wholeNum.append(sheet.cell(row=n, column=1).value)` to
accumulate a list.

