Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,104 questions

40,777 answers

573 users

How to create permutation of 4 letters based on string in Python

1 Answer

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

for s in permutation:
    print(s)
 

         
  
  
'''
run:

abcd
abdc
acbd
acdb
adbc
adcb
bacd
badc
bcad
bcda
bdac
bdca
cabd
cadb
cbad
cbda
cdab
cdba
dabc
dacb
dbac
dbca
dcab
dcba
          
'''

 





answered May 12, 2020 by avibootz

Related questions

1 answer 72 views
1 answer 72 views
1 answer 77 views
1 answer 82 views
1 answer 78 views
...