def truncate_text(text, maxlen=128, suffix='...'):
 if (len(text) >= maxlen):
  return (text[:maxlen].rsplit(' ', 1)[0] + suffix)
 return text

def truncate_text ( text , maxlen = 128 , suffix = '...' ) : if ( len ( text ) >= maxlen ) : return ( text [ : maxlen ] . rsplit ( ' ' , 1 ) [ 0 ] + suffix ) return text
return as many characters as possible without going over the limit .