- 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
11 Antworten
+ 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
Denise Roßberg - avatar
+ 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
B Thanuja - avatar
0
Output : IndentationError Output (with correct indentation) : 5
6th Feb 2022, 3:44 PM
Da GD Bot
Da GD Bot - avatar
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
Junior - avatar
0
its ans is 5
4th Jan 2023, 4:26 PM
Engr.Ayesha Liaqat
Engr.Ayesha Liaqat - avatar
0
answer = 3 but plz explain it
10th Sep 2023, 11:50 AM
B Sa
B Sa - avatar
0
answer is 3
9th Oct 2023, 4:34 AM
Amrutha Varshini
Amrutha Varshini - avatar
0
@&@@
20th Jun 2024, 9:21 PM
Maereg Kahsay
Maereg Kahsay - avatar