Skip to content

Instantly share code, notes, and snippets.

@rummykhan
Created September 26, 2017 19:15
Show Gist options
  • Save rummykhan/51a43d2eecf338597103b02000be8f83 to your computer and use it in GitHub Desktop.
Save rummykhan/51a43d2eecf338597103b02000be8f83 to your computer and use it in GitHub Desktop.
Find the permutations of a string
def permutations(s):
result = [x for x in s]
copy = []
for i in s:
for v in result:
copy.append(i + v)
result = copy + result
return result
print(permutations('rehan'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment