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>

<p>Split the string into separate lines, then center each line. Remember to either print each line immediately within the function, build up a list, or yield each line rather than returning after the first line. You can also determine and use a calculated width rather than a static value.</p>

<pre><code>def border_sign(note):
    note = note.splitlines()
    m = len(max(note, key=len))
    yield ('-'*m).join('++')
    for line in note:
        yield ("|{:^%d}|" % m).format(line)
    yield ('-'*m).join('++')

print(*border_sign("STOP\nDANGER AHEAD\nDrive safely!"), sep='\n')
</code></pre>

python function python-3.x