title: Dynamic border around text in python
body: <p>I need to input a sentence and make a dynamic border around that sentence. The border needs to have a width that is inputted. When the length of the sentence is higher than the given width, a new line has to be printed and the border has to change in <strong>height</strong>. The sentence also has to be centered in the dynamic border</p>
  
  <p>I already tried this: </p>
  
  <pre><code>sentence = input()
  width = int(input())
  
  length_of_sentence = len(sentence)
  
  print('+-' + '-'*(width) + '-+')
  
  for letter in sentence:
      print('| {0:^{1}} |'.format(letter, width - 4))
  
  print('+-' + '-'*(width) + '-+')
  </code></pre>
  
  <p>but then each letter with a new line is printed and that's not what I need.</p>
  
  <p>A great example is the following;</p>
  
  <p><strong>Input</strong> </p>
  
  <pre><code>sentence = "You are only young once, but you can stay immature indefinitely."
  width = 26
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <pre><code>+----------------------------+
  | You are only young once, b |
  | ut you can stay immature i |
  |         ndefinitely.       |
  +----------------------------+
  </code></pre>