ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(''.join(c.upper() if i % 2 else c for i, c in enumerate('python')))
  1. A. pYtHoP
  2. B. qYtHoN
  3. C. pYtHoM
  4. D. pYtHoN

Correct answer: D. pYtHoN

enumerate counts from 0, so indices 1, 3 and 5 are uppercased. The letters at even positions keep their case.

More Python Programming questions

Exams that ask this topic