I am trying to generate a list of all possible number combinations within a set of four numbers using all numbers from 0 through 9.
I'm getting close but the output doesn't show every possible combination starting from 0000 all the way to 9999.
Any clues as to why the following code is dropping certain combinations?
def permgen(items, n): if n==0: yield [] else: for i in range(len(items)): for cc in permgen(items[:i]+items[i+1:],n-1): yield [items[i]]+cc if __name__=="__main__": for c in permgen(['0','1','2','3','4','5','6','7','8','9'],4): print ''.join(c)