I noticed that when I did "heelo".split("e")
, it would return ['h', '', 'lo']
. Why is there an empty/a whitespace item in the list? Shouldn't it have been ['h', 'lo']
?
I am confused on why I received that result, instead of what I had expected and would appreciate if someone could explain me the functionality of split
better.
From the Python docs:
Your string is divided between the first
e
and seconde
, but there is no character there, so you get an empty character back''