ProgrammingModerateInfosys · Accenture · Capgemini pattern

What is printed?

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

Correct answer: B. ['a', 'b', '', 'c'] 3

split(",") with a given separator keeps the empty field between the two commas. split() with no argument splits on runs of whitespace and drops empty strings, so "a b c" gives 3 parts.

More Python Programming questions

Exams that ask this topic