- 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)
11 Answers
+ 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
+ 2
answer is 3 and i need to understand how can reach it
+ 1
thanks a lot
+ 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)
0
Output : IndentationError
Output (with correct indentation) : 5
0
i want solve-way
answer is 3
0
Can you share us the code? mahdi
0
its ans is
5
0
answer = 3
but plz explain it
0
answer is 3
0
@&@@