permute a list python with given condition code example Example: all permutations python import itertools print(list(itertools.permutations([1,2,3])))