Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Cut Sentence by hillelna
def cut_sentence(line, length):
'''
Cut a given sentence, so it becomes shorter than or equal to a given length.
'''
# case line is shorter
if len(line)<=length:
return line
# case length ends on a ' '
if line[length]==' ':
return line[:length] + '...'
# case length shorter than first word
if length
March 11, 2020