# Question

How to shortening a string without cutting words? For example, I have a string called Hello World, whose length is 11. I want to shorten its length to less than 6, which would be Hello W, but W is not a full word, we need to remove it. So the result is ony a word Hello. The following code is to solve the problem, written in python.

Share