def truncate_words(content, length=10, suffix='...'):
 split = content.split()
 if (len(split) <= length):
  return ' '.join(split[:length])
 else:
  return (' '.join(split[:length]) + suffix)

def truncate_words ( content , length = 10 , suffix = '...' ) : split = content . split ( ) if ( len ( split ) <= length ) : return ' ' . join ( split [ : length ] ) else : return ( ' ' . join ( split [ : length ] ) + suffix )
truncates a string after a certain number of words .