Search⌘ K

Splitsies

Discover how Python's split method treats whitespace and separators differently depending on arguments. Learn to predict the results of splitting strings with various inputs, including empty strings, to handle string parsing more effectively.

We'll cover the following...

If you think splitting a pizza is hard, check this out:

Python 3.5
print('a'.split())
# is same as
print('a'.split(' '))
# but
print(''.split())
# isn't the same as
print(''.split(' '))

Explanation

  • It might appear at first that the default separato
...
...