I have a list and two values to compare:
mylist = [1, 2, 3, 4, 5]
a = 2
b = 3
I want to check if the values in the list conform the if statement:
for i in mylist:
if i <= a:
print "OK"
elif i >= a and i < b:
print "WARNING"
elif i >= b:
print "CRITICAL"
However it stops at the first match and doesnt chek the other values in the list. Please help to correct the code. Thanks.
Aucun commentaire:
Enregistrer un commentaire