Answers for "python generate all combinations of strings"

3

python print combinations of string

import itertools
 
if __name__ == '__main__':
 
    nums = list("ABC")
    permutations = list(itertools.permutations(nums))
 
    # Output: ['ABC', 'ACB', 'BAC', 'BCA', 'CAB', 'CBA']
    print([''.join(permutation) for permutation in permutations])
Posted by: Guest on May-26-2021

Code answers related to "python generate all combinations of strings"

Python Answers by Framework

Browse Popular Code Answers by Language