- 1

# How many numbers will the following code output? i=0 while True: i+=1 if(i == 2): continue if(i == 5): break print(i)

6th Feb 2022, 3:40 PM
mahdi
+ 5
mahdi i = 0 while True: i += 1 if i == 2: continue if i == 5: break print(i) i gets 1, is not 2 and not 5, so print 1 i gets 2 -> continue (restarts the loop) i gets 3 -> print 3 i gets 4 -> print 4 i gets 5 -> break (ends the loop) So the loop prints 1,3,4
6th Feb 2022, 5:07 PM
Denise RoÃŸberg
+ 2
answer is 3 and i need to understand how can reach it
6th Feb 2022, 3:46 PM
mahdi
+ 1
thanks a lot
6th Feb 2022, 5:36 PM
mahdi
+ 1
How many numbers will the following code output? i=0 while True: i+=1 if(i == 2): continue if(i == 5): break print(i)
2nd Jul 2022, 4:21 AM
B Thanuja
0
Output : IndentationError Output (with correct indentation) : 5
6th Feb 2022, 3:44 PM
Da GD Bot
0
i want solve-way answer is 3
6th Feb 2022, 3:47 PM
mahdi
0
Can you share us the code? mahdi
6th Feb 2022, 3:48 PM
Junior
0
its ans is 5
4th Jan 2023, 4:26 PM
Engr.Ayesha Liaqat
0
answer = 3 but plz explain it
10th Sep 2023, 11:50 AM
B Sa
0