jeudi 12 juillet 2018

Index error in "if" loop in python

I have written a very simple code using if loop which compares the data of the tuple list values. But I am not sure why am I the getting an error in the if statement.

    Error : IndexError('list index out of range',)

Code :

    for i in range(2,51):
    sheet1 = wb['sheet1'] 
    rowA ='B{0}'.format(i)
    rowB ='AO{0}'.format(i)
    tup1.append(sheet1[rowA].value)
    tup2.append(sheet1[rowB].value)
    sheet2 = wb['sheet2'] 
    rowC = 'O{0}'.format(i)
    tup3.append(sheet2[rowC].value)
    sheet3 = wb['sheet3']
    if tup3[i] == 'Student':
      desc = sheet3['C14'].value
    elif tup3[i] == 'Teacher':
      desc = sheet3['C10'].value
    else :
      desc = sheet3['C2'].value

Aucun commentaire:

Enregistrer un commentaire