from itertools import permutations pw = "0123456789" c = permutations(pw, 3) for i in c: print("".join(i))