I'm new to Python (I've only used C) and I've discovered new loops such as for/else... So I wonder if I'm ignoring a cleaner way to handle this loop:
flag = 0
for i in range (n):
if not flag and condition_1:
statement_1
flag = 1
if flag and condition_2:
statement_2
I need to keep the for counting, because the n-th element that satisfy condition_2 could come strictly after the element I look for condition_1
Aucun commentaire:
Enregistrer un commentaire