Help me in solving PYTH111 problem

My issue

Learning course: Learn Python
Problem Link: CodeChef: Practical coding for everyone

@greyghost77
The question is following block of code the number of times the following code will print 'Python’.

i = 0
while i <= 5:
    print("Python")
    if i == 4:
         break
    i = i + 2

Here, (i==0) at start, now we enter the while loop.

  • Iteration 1: i=0, loopcondition satisfied. Python is printed once. i becomes 2.

  • Iteration 2: i=2, loop condition satisfied. Python printed again, total count=2. i becomes 4.

  • Iteration 3: i=4, loop condition satisfied. Python printed again, total count=3. if condition is satisfied, control breaks from while loop.

So, in the end, Python is printed 3 times for the above code block.