ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print(' '.join(['a', '', 'b']), ' '.join([]) == '', '-'.join('abc'), 'x'.join(['1', '2', '3']))
  1. A. a b True a-b-c 1x2x4
  2. B. a b False a-b-c 1x2x3
  3. C. a b True a-b-c 1x2x3
  4. D. a b True abc 123

Correct answer: C. a b True a-b-c 1x2x3

Joining an empty list gives the empty string, and joining an empty element keeps two separators in a row. '-'.join('abc') puts a hyphen between each character.

More Python Programming questions

Exams that ask this topic