for tens in range(1,10): for ones in range(0,11): res=tens*10+ones -tens - ones h[res]=True h.keys() [36, 72, 9, 45, 81, 18, 54, 27, 63]