How to use 'count all permutations of a string' in Python

Every line of 'count all permutations of a string' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
6def permute(string: str) -> typing.Iterator[str]:
7 """
8 >>> list(permute('ABC'))
9 ['ABC', 'ACB', 'BAC', 'BCA', 'CAB', 'CBA']
10 """
11 yield from map("".join, itertools.permutations(string))
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code


Related snippets