ProgrammingHardTCS NQT · Wipro pattern

What is printed?

What is printed?
print(list(enumerate(['x'], 1))[0][0] + 1)
  1. A. 1
  2. B. 2
  3. C. 0
  4. D. 3

Correct answer: B. 2

enumerate with start=1 gives index 1 for the first item, and adding 1 gives 2.

More Python Programming questions

Exams that ask this topic