<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def margin(text):
 r"""Add a margin to both ends of each line in the string. Example: ' line1 \n line2 ' """

    lines = str(text).split('\n')
    return '\n'.join('  {}  '.format(l) for l in lines)