Skip to content

Instantly share code, notes, and snippets.

@Nickikku
Created July 18, 2017 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nickikku/c33b34cb73328ad7cd57ec463c5d29a7 to your computer and use it in GitHub Desktop.
Save Nickikku/c33b34cb73328ad7cd57ec463c5d29a7 to your computer and use it in GitHub Desktop.
def front_back(str):
if len(str) <= 1: #if the string only has one character, it returns just that one.
return str
a = str[1:-1] #takes the string without the first and the last character.
return str[-1] + a + str[0] #adds the last, the middle and the first sections together.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment