ProgrammingHardTCS NQT · Accenture

What is printed?

What is printed?
print('a,b,,c'.split(','), 'a b'.split())
  1. A. ['a', 'b', '', 'c'] ['a', 'b']
  2. B. ['a', 'b', 'd'] ['a', 'b']
  3. C. ['a', 'b', '', 'c'] ['a', '', 'e']
  4. D. ['a', 'x', 'c'] ['a', 'b', 'c']

Correct answer: A. ['a', 'b', '', 'c'] ['a', 'b']

split with a comma keeps the empty field between the two commas. split without arguments splits on runs of whitespace and drops empty fields.

More Python Programming questions

Exams that ask this topic