ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
try:
    'abc'.split('')
except ValueError as e:
    print(e)
  1. A. ['a', 'b', 'c']
  2. B. no output
  3. C. ValueError
  4. D. empty separator

Correct answer: D. empty separator

split() with an empty separator raises ValueError with the message 'empty separator'. Only the no-argument form splits into characters, and list(s) is the usual replacement.

More Python Programming questions

Exams that ask this topic