code: def wrap_text(text, width):
          
          out = []
          for paragraph in text.splitlines():
              # Wrap returns an empty list when paragraph is a newline. In order
              # to preserve newlines we substitute a list containing an empty
              # string.
              lines = wrap(paragraph, width=width) or ['']
              out.extend(lines)
          return out
docs: Wrap text paragraphs to the given character width while preserving
          newlines.