How to generate all possible permutations of 3 characters in Python

1 Answer

0 votes
from itertools import permutations
 
s = "abc"

p = permutations(s) 

for item in list(p): 
    print(item) 
 

  
      
'''
run:
      
('a', 'b', 'c')
('a', 'c', 'b')
('b', 'a', 'c')
('b', 'c', 'a')
('c', 'a', 'b')
('c', 'b', 'a')

'''

 



answered Oct 1, 2021 by avibootz
...