Skip to content

Instantly share code, notes, and snippets.

@mevangelista-alvarado
Created June 28, 2018 21:38
Show Gist options
  • Save mevangelista-alvarado/93356c0b2f3c084cb3396e15ac3703d4 to your computer and use it in GitHub Desktop.
Save mevangelista-alvarado/93356c0b2f3c084cb3396e15ac3703d4 to your computer and use it in GitHub Desktop.
This a test for cut a phrase with a limit, without cutting words
# Variables
test = u'Hola a todo el mundo' # Enter a phrase
lenght = 10 # Enter a number
test_list = test.split()
i = len(test_list)
while i<=len(test_list):
phrase = " ".join(list[0:i])
if len(phrase)<lenght:
print(phrase)
break
i-=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment