ProgrammingHardHCL · Tech Mahindra · Python placement

What does the following Python 3 code print? def f(): for i in range(3): if i == 1: continue print(i, end="") print() f()

  1. A. 0 2
  2. B. 012
  3. C. 01
  4. D. 02

Correct answer: D. 02

continue skips printing when i==1, so only i=0 and i=2 are printed (with no separator, since end="").

More Python Programming questions

Exams that ask this topic