mercredi 7 décembre 2016

Multiple IF statements in python

I am trying to print the content in a specific cell. i know the cells i want to check before extracting the content to the output. i am using multiple IF statements for this :

if lineCount == 5:
                if line[0]:
                    print line[0],'A5'
                    OPfound = 1
                    break
                if line[1]:
                    print line[1],'B5'
                    OPfound = 1
                    break
            if lineCount == 4:
                if line[0]:
                    print line[0],'A4'
                    OPfound = 1
                    break
                #if line[1]:
                #   print line[1],'B4'
                #   OPfound = 1
                #   break




The output is in the form :- extracted content, cell number

what i am trying to do is first check if there is any content in A5 - if there is content then extract it...else check for content in B5 - if there is content then extract it...else check content in A4

i am getting output for B5 and A4...but NOT FOR A5 help me fix it please...

also how do i check content in B4 ONLY if there is no content in A5,B5 and A4...

Aucun commentaire:

Enregistrer un commentaire