This works:
def gen():
yield False
yield True
yield oups
if any(gen()):
print('At least one is True')
# At least one is True
But this fails:
if any(iter([False, True, oups])):
print('At least one is True')
# NameError: name 'oups' is not defined
Is there a way to transform the second code into the first one without too much effort ?
Aucun commentaire:
Enregistrer un commentaire