+ 2
No out put - Python
Why am I getting "No Output" in the result? i = 10 while i > 0: if i == 3: continue else: print (i) i -= 1
3 Respostas
+ 3
Your code got stuck in an infinite loop, Code Playground terminates your code because of this behaviour.
When <i> value reaches 3 the condition `i == 3` evaluates to true, and `continue` is executed. But <i> value is not decremented, so when the loop goes back for another round <i> value remains to be 3. This is where the loop becomes infinite.
Simply add `i -= 1` before the `continue` statement and it'll work.
+ 1
And if you want to see the output before reaching 3, you have to flush it at each print:
print(i, flush=True)
+ 1
If u try it in a standered python compiler like pycharm or visual studio code ,you will get output:
10
9
8
7
6
5
4
but then it will cause infinite loop but in sololearn it will give no output.