Change language

Python | Permutation of a given string using a built-in function

| |

Examples:

` Input: str = ’ABC’ Output: ABC ACB BAC BCA CAB CBA `

We have a solution to this problem, please refer to Permutations of the given string using link STL . We can also solve this problem in python using

` # Function to find permutations of a given string `

` from ` ` itertools ` ` import ` ` permutations `

` def ` ` allPermutations (` ` str ` `): `

` # Get all permutations of the line & # 39; ABC & # 39 ; `

`  permList = permutations ( str ) `

`     # print all permutations   for perm in list (permList): print (’’ .join (perm))    # Driver program if __ name__ = = "__ main__" :   str = ’ ABC’ allPermutations ( str ) `

Output:

` ABC ACB BAC BCA CAB CBA `

Shop

Learn programming in R: courses

\$

Best Python online courses for 2022

\$

Best laptop for Fortnite

\$

Best laptop for Excel

\$

Best laptop for Solidworks

\$

Best laptop for Roblox

\$

Best computer for crypto mining

\$

Best laptop for Sims 4

\$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

NUMPYNUMPY

How to convert Nonetype to int or string?

NUMPYNUMPY

How to specify multiple return types using type-hints

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method