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: | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
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)

29th Jun 2022, 10:23 PM
MAnny
MAnny - avatar
1 ответ
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
29th Jun 2022, 11:08 PM
Мартин 😑🎵
Мартин 😑🎵 - avatar