Created
July 18, 2017 09:25
-
-
Save Nickikku/c33b34cb73328ad7cd57ec463c5d29a7 to your computer and use it in GitHub Desktop.
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 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