numbers= [12,75,150,180,145,525,50]
for item in numbers:
if item>150:
continue
if item>500:
break
if item%5==0:
print(item)
So when I run this, the output should ignore the value 50 because the value 525 should have caused the loop to break beforehand. The output is 75, 150, 145, 50 but should’nt be including the last 50 integer. Thanks!
Thanks for the reply! In your response, but doesnt the continue operation just skip ahead to the next item in the list? It will see 12 (ignore), 75 (print), 150 (print), 180 (continue), 145 (print), 525 (break- leave loop) no?
No, it has nothing to do with the ordering of breaks and continues but the ordering of overlapping conditions where entering one prevents entering the other.