On Thu, 16 May 2013 08:00:25 -0700, loial 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. > mystr.rsplit("_",1)[0]