ProgrammingHardTCS CodeVita · GATE CS · Advanced

What does the following Python 3 code print? print(*[1, 2, 3], *[4, 5], sep=",")

  1. A. [1, 2, 3],[4, 5]
  2. B. 1,2,3,4,5
  3. C. 1 2 3 4 5
  4. D. 1,2,3 4,5

Correct answer: B. 1,2,3,4,5

Both lists are unpacked into individual positional arguments to print, which joins all five with the given separator.

More Python Programming questions

Exams that ask this topic