Question
Asked By – orokusaki
What is the point of '/segment/segment/'.split('/')
returning ['', 'segment', 'segment', '']
?
Notice the empty elements. If you’re splitting on a delimiter that happens to be at position one and at the very end of a string, what extra value does it give you to have the empty string returned from each end?
Now we will see solution for issue: Why are empty strings returned in split() results?
Answer
This question is answered By – John La Rooy
This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0