samedi 14 novembre 2020

What's the best way to call a function across multiple if/elif statements?

I currently have a bit of code that looks like this:

if a:
    if b:                
        do_b()
        do_e()               
    elif c:                
        do_c()
        do_e()                                          
    elif d:
        do_d()
        do_e()

Is there a better way of formatting this rather than repeating do_e() 3 times?

Aucun commentaire:

Enregistrer un commentaire