How to create all possible permutations of a given string in Python

1 Answer

0 votes
from itertools import permutations 
  
s = "xyz"
  
permutation = [''.join(e) for e in permutations(s)] 

for s in permutation:
    print(s)
 

         
    
'''
run:

xyz
xzy
yxz
yzx
zxy
zyx
          
'''
 

 



answered May 12, 2020 by avibootz
...