Created
September 26, 2017 19:15
-
-
Save rummykhan/51a43d2eecf338597103b02000be8f83 to your computer and use it in GitHub Desktop.
Find the permutations of a string
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 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