Created
April 11, 2017 11:27
-
-
Save opethe1st/609eac99c4694ec1b31186a68ba9b663 to your computer and use it in GitHub Desktop.
lastword function
This file contains hidden or 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 lastWord(word): | |
if len(word)==1: | |
return word | |
lastletter = word[-1] | |
restOfWord = lastWord(word[:-1]) | |
if ord(lastletter)>=ord(restOfWord[0]): | |
return lastletter+restOfWord | |
else: | |
return restOfWord+lastletter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment