If one IF is satisfied, skip the rest in the nest...

Denis McMahon denismfmcmahon at gmail.com
Wed Oct 21 15:48:09 EDT 2015


On Wed, 21 Oct 2015 10:31:04 -0700, bigred04bd3 wrote:

> So here what I have, I have a 3 IF's within the same level.  If one IF
> is satisfied, I would like to "skip" the other IFs and continue with my
> code.

c1 = wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and 
     wb1_sheet1.cell(row=cell + 1, column=3).value == 0

c2 = wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and 
     wb1_sheet1.cell(row=cell + 2, column=3).value == 0

c3 = wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and 
     wb1_sheet1.cell(row=cell + 3, column=3).value == 0

if c1:
    if c2:
        if c3:
            # c1 && c2 && c3
            # 4 second open
        else:
            # c1 && c2
            # 3 second open
    else:
        # only c1
        # 2 second open

Each condition only gets evaluated once.

-- 
Denis McMahon, denismfmcmahon at gmail.com



More information about the Python-list mailing list