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