Answers for "how to find all possible permutations of a given string in python"

12

all permutations python

import itertools
print(list(itertools.permutations([1,2,3])))
Posted by: Guest on May-02-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

Code answers related to "how to find all possible permutations of a given string in python"

Python Answers by Framework

Browse Popular Code Answers by Language