Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Python | Output Type | Question 5

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

What is the output of the following program : 

Python3




i = 0
while i < 3:
    print i
    i += 1
else:
    print 0


(A)

0 1 2 3 0

(B)

0 1 2 0

(C)

0 1 2

(D)

Error


Answer: (B)

Explanation:

The else part is executed when the condition in the while statement is false.


Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Last Updated : 19 Jun, 2019
Like Article
Save Article
Similar Reads