Divide long string into x character long lines or shorter but don't break words
<pre><code>import textwrap
print(textwrap.fill(text, 50))
</code></pre>

<p>I found this function, but it breaks words. I also found <a href="https://stackoverflow.com/questions/1678051/divide-long-string-into-60-character-long-lines-but-dont-break-words">Divide long string into 60 character long lines but don&#39;t break words</a>, but it uses C# not Python.</p>