import itertools wires=["red", "green", "blue", "yellow"] for i in itertools.permutations(wires): print i