I am trying to create a variable based in various business rules from another variable. Please see example below. When I am dealing with only one word I need to use as a condition I use the following code:
physical = ['light','sedentary','medium','heavy']
def matcher(x):
for i in physical:
if i.lower() in x.lower():
return i
else:
return 'other'
My issue is when that are multiple words that match in a sentence, in this specific cases I wan to call 'mix'.
Physical Demand Result
Light to medium with occasional heavy levels mix
Light light
Medium medium
tks.
Aucun commentaire:
Enregistrer un commentaire