0

Where is print(i) in the output

i = 0 while True: i = i +1 if i == 2: print("Skipping 2") continue if i == 5: print("Breaking") break print(i) print("Finished")

6th Jun 2017, 6:10 AM
Nipun Grover
Nipun Grover - avatar
1 Resposta
+ 2
In python we are using indentation instead of curly braces which will reduce the code complexity and it will be easy to write the code. under while loop u have 2 if condition and print(i) is the last statement of while loop. based on the above statement it will begin with while statement and i becomes i=i+1 that is i=1 then it will check i==2 (false) then it will check i==5(false)//statment under if condition is not executed. then it will display i using print(i) that is 1 then it will increment i=i+1 (i=2) it will print skipping 2 (i==2)//true and it continue and when i==5 it print beraking then it it out of loop and print finished
6th Jun 2017, 6:24 AM
Nanda Balakrishnan