lundi 31 août 2015

Check first condition in IF and test in the next statement too in Python

I'd like to understand something in Python - IF condition. Using this example code:

num = 1

if (num == 1):
    print ("op 1")
elif (num < 2):
    print ("op 2")
elif (num <= 1):
    print ("op 3")
elif (num != 1):
    print ("op 4")
else:
    print ("Fail")

print ("End")

I'll get the first condition and then go to the end.

How can I do it to check, for example, the first and if True go check the next condition too? And check all of them?

Trying to use CONTINUE not worked; I used a bunch of IFs instead of IF->Elif, but is this the right way to do?

Aucun commentaire:

Enregistrer un commentaire