Formatting loop for strings
<p>I'm having trouble formatting the strings below. Trying to keep the message centered with the borders, but having a hard time executing it. Below is what output I want and below that is my code I have so far. Note: I need to have a space on the left and right columns of the longest line and I need to utilize the split() func.</p>

<pre><code>+---------------+
|     STOP!     |
| DANGER AHEAD  |
| Drive Safely! |
+---------------+

def border_sign(note):
    letter_count = 0
    for i in note:
        letter_count += 1
        return "+-------+\n| {} |\n+-------+\n".format(note)
 border_sign("STOP\nDANGER AHEAD\nDrive safely!")
</code></pre>

<pre><code>def border_sign(x):
    splitted = x.splitlines()
    M = max(map(len,splitted))
    horiz = '+-%s-+' % (M*'-')
    patiz = '| {0: ^%d} |' %  M
    print(horiz,*map(patiz.format,splitted), horiz, sep='\n')

border_sign("STOP\nDANGER AHEAD\nDrive safely!")
</code></pre>

<p><code>patiz.format</code> is a function, then can be used in <code>map</code></p>

python function python-3.x