ProgrammingHardTCS NQT · Wipro pattern

What is printed?

What is printed?
print('-'.join(map(str, range(3, 0, -1))))
  1. A. 3-2-1-0
  2. B. 1-2-3
  3. C. 3-2-1
  4. D. 2-1-0

Correct answer: C. 3-2-1

range(3, 0, -1) yields 3, 2 and 1, and map(str) converts them before the join. The stop value 0 is never included.

More Python Programming questions

Exams that ask this topic