Code to print possible permutation of a string | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Code to print possible permutation of a string

7th May 2017, 6:48 AM
Atinderjit Singh Saini
Atinderjit Singh Saini - avatar
2 Answers
+ 1
You can use 'permutations' from the 'itertools' module: import itertools as it initial = input('Please enter a string') perms = it.permutations(initial) print('\nThe permutations for {} are:\n'.format(initial)) for perm in perms: print(''.join(perm), end = ' ')
7th May 2017, 7:02 AM
Klaus-Dieter Warzecha
Klaus-Dieter Warzecha - avatar
0
Without using any tool
7th May 2017, 5:09 PM
Atinderjit Singh Saini
Atinderjit Singh Saini - avatar