human
how to get the last part of a string before a certain character?
assistant
Here is some code to split a string `x` by last occurrence of character `-`

print(x.rpartition('-')[0])

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.