Splitting Strings Related Tips
Learn how to split strings efficiently in Python.
We'll cover the following
str.split()
by white spaces
The str.split()
method can be called in four ways, though two tend to cause problems. Those are:
- Without the separator
- With a separator
When the method is called with a separator, the method removes the separator string as a whole (not the individual separator characters) from the split string and returns a list of leftovers:
Get hands-on with 1400+ tech skills courses.