title: How to split sentence into words which fit given space?
body: <p>I have a dictionary where key is the number and value is a string. I would like it to print those strings in lines. BUT the lines has length let's say 15, so there can be 15 chars in line. If adding current word to line makes it longer than 15 , the current word is moved to the next line. I think it can be done with join function, but i am not quite sure how it should look like. The only result I got now are words or chars printed in every line.</p>
  
  <pre><code>dictionary = { 1 : "hello i am Alice. i have a cat", 
                 2 : "his name is Bob"
               }
  
  for elem in dictionary:
      words = dictionary[elem].split(" ")
      dictionary[elem] = "\n".join(....)
  </code></pre>
  
  <p>The result I am aiming at looks like this:</p>
  
  <pre><code> hello i am 
   Alice. i 
   have a cat
   his name 
   is Bob.
  </code></pre>