how can I make the func. show all the bad values and not just one?
def get_bad_results(person_results):
for i in person_results:
if i[1]>i[3] or i[1]<i[2]:
return i[0]
test_results = [["White blood cells",8.5,2,7],
["Neutrophils",5.3,2.5,5],
["Red blood cells", 12.4, 9,15]]
a = get_bad_results(test_results)
print a
show White blood cells
instead of
White blood cells, Neutrophils
As you expect several results per call, it is the best to use a generator function:
or a generator expression:
so that
gives the output
For the other function, do
or just
Edit:
For many
get_bad_results(), turning it into a list could be memory-intensive.So instead of
len(list(get_bad_results(i))) == 0you could useand then