<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def replace_whitespace(text, SAFE_SPACE='|<^>|', insert=True):
 """ Replace non-strippable whitepace in a string with a safe space """

    if insert:
        # replace whitespace with safe space chr
        args = (' ', SAFE_SPACE)
    else:
        # replace safe space chr with whitespace
        args = (SAFE_SPACE, ' ')

    return '\n'.join(line.strip().replace(*args)
                     for line in str.splitlines(text))