<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def fmt_margin(text, margin = None, margin_left = None, margin_right = None, margin_char = ' '):
 """ Surround given text with given margin characters. """

        if margin_left is None:
            margin_left = margin
        if margin_right is None:
            margin_right = margin
        if margin_left is not None:
            text = '{}{}'.format(str(margin_char)[0] * int(margin_left), text)
        if margin_right is not None:
            text = '{}{}'.format(text, str(margin_char)[0] * int(margin_right))
        return text