ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print(*[f'{i}{ch}' for i, ch in enumerate('ab', 1)])
  1. A. 1a 2b
  2. B. 0a 1b
  3. C. 2a 3b
  4. D. 1a 2b 2

Correct answer: A. 1a 2b

enumerate with start=1 counts from 1 rather than 0. Each pair is joined into a string in the comprehension, and print with * shows each one separated by a space.

More Python Programming questions

Exams that ask this topic