Last active
June 12, 2016 09:02
-
-
Save brettfreer/cc9a63ebaa306174285c5adc64dc1064 to your computer and use it in GitHub Desktop.
Swap positions i and j in string s
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 swap(s, i, j): | |
return ''.join((s[:i], s[j], s[i+1:j], s[i], s[j+1:])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment