ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print(*[1, 2, 3], sep="-", end="!\n")
  1. A. [1, 2, 3]!
  2. B. 1-2-3!
  3. C. 1 2 3!
  4. D. 1-2-3-!

Correct answer: B. 1-2-3!

*[1, 2, 3] unpacks the list into three separate arguments. sep goes only BETWEEN them, and end replaces the final newline, giving 1-2-3!.

More Python Programming questions

Exams that ask this topic