dimanche 28 juin 2015

Continue to next elif after elif condition is met

I am checking for a large number of conditions (hundreds), where each one looks something like this:

s = "string"
match = True

if "x" in s:
   var_1 = "something"
elif "y" in s:
   var_2 = "something else"
elif "z" in s:
   var_1 = "something something"
   var_2 = "some thing"
else match = False

Problem is that I want to continue to check the rest of the elifs even if an elif condition is met.

Running everything as if instead of elif does not work for what I'm trying to do, since I need else match = False to trigger if no condition is met.

Is there a work-around?

Aucun commentaire:

Enregistrer un commentaire