mercredi 19 septembre 2018

if else not working inside for scope though if elif is working in python [on hold]

Why isn't the control moving to else in

    def test(a=None): 
        b = 'arghya'
        c = 'deep'
        for each_con in content:
            if a is not None:
                if b == c:
                    print(a)
            else:
                print(b)

though it is working fine for elif, i.e.

    def test(a=None): 
        b = 'arghya'
        c = 'deep'
        for each_con in content:
            if a is not None:
                if b == c:
                    print(a)
            elif a is None:
                print(b)

Aucun commentaire:

Enregistrer un commentaire