while loop function | continue | break | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

while loop function | continue | break

i=0 while True: i=i+1 print(i) if i==2: print('2 was skipped') continue if i==5: print('break') break print('finished') output is 1 2 2 was skipped 3 4 5 break finished the problem is that 2 how to i remove that some one plese help me

15th Nov 2020, 8:20 AM
Antony Praveenkumar M
Antony Praveenkumar M - avatar
2 Answers
+ 3
Try this: i=0 while True: i=i+1 if i==2: print('2 was skipped') continue elif i==5: print('break') break else: print(i) print('finished')
15th Nov 2020, 8:29 AM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
0
it's good but i need using only continue and break operation and thank for your kind information I got it i=0 while True: i=i+1 print(i) if i==1: print('2 was skipped') i=i+1 continue if i==5: print('break') break print('finished')
15th Nov 2020, 8:55 AM
Antony Praveenkumar M
Antony Praveenkumar M - avatar