practicepython.in
python exercises
171 exercises

Daily #7 · 5 October 2026

Splitting on a space Easy

What does this print?

print("to  be".split(" "))
  1. A['to', ' ', 'be']
  2. B['to', 'be']
  3. C['to be']
  4. D['to', '', 'be']
Show the answer

D: ['to', '', 'be']

Why: There are two spaces, so splitting on exactly one space leaves an empty string between them. split() with no argument splits on any run of whitespace and drops the empties.

Play today’s puzzle →