you can also add in
if x
to ensure that the chunk produced by split
has some content, i.e. result = [x + sep for x in text.split(sep) if x]