<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _swap_ending(s, ending, delim='_'):
 """ Replace the ending of a string, delimited into an arbitrary number of chunks by `delim`, with the ending provided Parameters s : string string to replace endings ending : string string used to replace ending of `s` delim : string string that splits s into one or more parts Returns ------- new string where the final chunk of `s`, delimited by `delim`, is replaced with `ending`. """

    parts = [x for x in s.split(delim)[:-1] if x != '']
    parts.append(ending)
    return delim.join(parts)