Not working | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Not working

k =1 while 1 ==1 or 5 !=5 : print(k) k=k+1 if k ==5: print("skipping 5") continue if k == 12: print("breaking") break

22nd Mar 2020, 1:50 PM
Bai Jilla
Bai Jilla - avatar
1 Answer
+ 1
Bai Jilla It's working fine and printing value till infinite because when k == 5 it will skip current iteration so it will go on next iteration. Next time k will be 6 and it will never go inside if condition and will print value till infinite. To avoid till infinite make second if statement with new block as Mirielle(20k XP Monthly till November) said like this:- k =1 while 1 ==1 or 5 !=5 : print(k) k=k+1 if k ==5: print("skipping 5") continue if k == 12: print("breaking") break
22nd Mar 2020, 2:52 PM
A͢J
A͢J - avatar