Answers for "given str permutation in python"

1

python all permutations of a string

>>> from itertools import permutations
>>> perms = [''.join(p) for p in permutations('stack')]
>>> perms
Posted by: Guest on November-08-2020
0

permutation of a string in python

# Function to find permutations of a given string
from itertools import permutations
  
def allPermutations(str):
       
     # Get all permutations of string 'ABC'
     permList = permutations(str)
  
     # print all permutations
     for perm in list(permList):
         print (''.join(perm))
        
# Driver program
if __name__ == "__main__":
    str = 'ABC'
    allPermutations(str)
Posted by: Guest on December-30-2021

Python Answers by Framework

Browse Popular Code Answers by Language