I understand why it is important to create blanks using split thanks to this question, but sometimes it is necessary not to grab them.
lets say you parsed some css and got the following strings:
s1 = 'background-color:#000;color:#fff;border:1px #ccc dotted;'
s2 = 'color:#000;background-color:#fff;border:1px #333 dotted'
both are valid css even though there is a semicolon lacking at the end of the string. when splitting the strings, you get the following:
>>> s1.split(';')
['background-color:#000', 'color:#fff', 'border:1px #ccc dotted', '']
>>> s2.split(';')
['color:#000', 'background-color:#fff', 'border:1px #333 dotted']
that extra semicolon creates a blank item in the list. now if I want to manipulate further I would need to test the beginning and end of each list, and remove them if they are blank, which is not that bad, but seems avoidable.
question:
is there a method that is essentially the same as split
but does not include trailing blank items? or is there simply a way to remove those just like a string has strip
to remove the trailing whitespace