Skip to content

Instantly share code, notes, and snippets.

@opethe1st
Created April 11, 2017 11:27
Show Gist options
  • Save opethe1st/609eac99c4694ec1b31186a68ba9b663 to your computer and use it in GitHub Desktop.
Save opethe1st/609eac99c4694ec1b31186a68ba9b663 to your computer and use it in GitHub Desktop.
lastword function
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