Q
What does this Python code print?
for i in range(3):
if i == 5:
break
else:
print("done")
-
A
done printed 3 times
-
B
Nothing
-
C
SyntaxError
-
D
done
Correct Answer:
D. done
Explanation:
A for loop's else block runs when the loop finishes without hitting break.