Created
August 19, 2016 16:34
-
-
Save Bl41r/69d13fa88f502fa5abdd32bac56ad831 to your computer and use it in GitHub Desktop.
code challenge 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def smart_substr(in_str, terminate='...'): | |
if len(in_str) <= 30: | |
return in_str + terminate | |
else: | |
if in_str[30] != ' ': | |
return ' '.join(in_str[0:30].split()[:-1]) + terminate | |
else: | |
return in_str[0:30] + terminate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
congratulations! you win the stump the chump award