vendredi 20 décembre 2019

Change python for loop based in a if question

I am trying to change the iterable of a for loop based on a passed parameter, something like the following:

bar = kwargs.get('bar', False)
if bar:
    for i in tqdm(range(10)):
else:
    for i in range(10):
    ...

Is there a way to do so?

Aucun commentaire:

Enregistrer un commentaire