Report Bug
Qus :

What will be the output of the following Python code?

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

Qus

निम्नलिखित Python कोड का आउटपुट क्या होगा?

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


Solution
B. 0 1 2 0



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



Report Bug