Python 3 Smart Truncate String Wihout Breaking Words

March 9, 2020
import textwrap
str  = textwrap.shorten('I live in Malaysia', width=11, placeholder='..')   # 'I live in..'

References:

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.