from itertools import permutations import itertools as it # Get all permutations of [1, 2, 3] list_of_numbers = range(1, 4) # one more than highest number perm = permu