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
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))

Related snippets