I have about 100 fields I need to make sure have non-empty values. To do this I am doing:
if all([field1, field2, ...]):
print 'ok'
else:
raise
However, I’d like to know which fields have the empty values, so I can prompt the user to correct those. Is there a straightforward way to show which fields have the empty values in a large-scale validation, using all() or another method?
Assuming that you store the ‘fields’ in a
dict:If it is a list and you want to know the indexes where the values are empty: