str.split takes a limit argument. Try your_string.split('_', 1) On 16 May 2013 16:11, "loial" <jldunn2...@gmail.com> wrote:
> I want to split a string so that I always return everything BEFORE the > LAST underscore > > HELLO_xxxxxxxx.lst # should return HELLO > HELLO_GOODBYE_xxxxxxxx.ls # should return HELLO_GOODBYE > > I have tried with rsplit but cannot get it to work. > > Any help appreciated > > -- > http://mail.python.org/mailman/listinfo/python-list >
-- http://mail.python.org/mailman/listinfo/python-list