ProgrammingModerateTCS NQT · Infosys

What is printed?

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

Correct answer: A. a-b-c True True x

join puts the separator only between items, so a join over two empty strings gives just the separator once. An empty list joined gives an empty string.

More Python Programming questions

Exams that ask this topic