Explain please (python)

i = 0 while 1==1: print(i) i = i + 1 if i >= 5: print("Breaking") break print("Finished") Is if statement executed before while statement? And why isn't 5 printed because it's true as 5 is greater or equals to 5 so that's true so it should be printed

3/31/2020 6:44:52 PM

Deepshikha Chhaperia

1 Answer

New Answer


When 4 is printed,in the next line i value become 5 so if statement will execute and it will break out of the while loop. So value 5 is not printed. If you print the i value after while loop,it will be 5