Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
pop words until it's short enough solution in Clear category for Cut Sentence by Phil15
def cut_sentence(line, length):
if len(line) <= length:
return line
words = line.split()
while True:
short = ' '.join(words)
if len(short) <= length:
return short + '...'
words.pop()
Feb. 28, 2020
Comments: