Skip to content

Instantly share code, notes, and snippets.

@brettfreer
Last active June 12, 2016 09:02
Show Gist options
  • Save brettfreer/cc9a63ebaa306174285c5adc64dc1064 to your computer and use it in GitHub Desktop.
Save brettfreer/cc9a63ebaa306174285c5adc64dc1064 to your computer and use it in GitHub Desktop.
Swap positions i and j in string s
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