<human>:  Remove final characters from string recursively - What's the best way to do this?
<bot>:

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