Post

@PythonPr the amount of people confidently stating 10, 14, 18 scares me for the future of software.
I had to actually had to run the code myself to see if I was the one going crazy since I knew that if statement with break would exit the while loop before 18 could print.

English

@PythonPr Code stop at 18 coz num get +4 till it reach 18 where the conditional statement break it
English

@PythonPr Dry Run:
num print
10 10
14 14
Output:
10
14
English

Answer:
10
14
18
Explanation:
The loop starts with num = 10 and runs while num < 20.
First iteration: print 10 → num += 4 → becomes 14
Second iteration: print 14 → num += 4 → becomes 18
Third iteration: print 18 → num += 4 → becomes 22
Now the if num == 18 check happens after increment, so it never triggers (since num becomes 22). Then the loop condition num < 20 fails, and the loop exits.
Key insight: break is never executed because the value skips over the check point after increment.
English

@PythonPr The loop increases num by 4 beginning with 10. So, the loop runs twice and 10 14 will print. After 14 prints, num becomes 18 and the if condition becomes true and break stops the loop. Final output is 10 14
English















