0
Please check out the code and explain to me how the break and continue loops works and I'm also confused with the i <= 0:
age=0 while age<120: age+=1 if age>=1 and age<=3: print("Chiled free ticket") continue print(age)
1 Antwort
0
break is for getting out of the loop when a condition is met
continue is for skiping when a condition is met
if you want even numbers without 2, or get out of the loop when you get to 8 maybe
for(int i = 0; i <= 10; ++i) {
if(i >= 8) break;
if(i == 2) continue;
if(i % 2 == 0) {
something else
}
}
This is more useful in some other problems nor here, its just an example