Shorten title to a certain length
<p>Given a title and a max_length, what would be the best way to shorten the title? The following is what I had in mind:</p>

<pre><code>def shorten_title(title, max_length):
    if len(title) &gt; max_length:
        split_title = title.split()
        length = len(title)
        n = 1
        while length &gt; max_length:
            shortened_title = split_title[:length(split_title)-n]
            n+=1
        return shortened_title
    else:
        return title
</code></pre>
