I’m making a program that prints all possible mixtures of numbers from 0 to 9 and I want to delete the numbers that my code puts before the actual number if the output is less than 6 places.
I’ve tried putting “” before 0 in every array, but it also puts random spaces in the output.
Class1 = [0,1,2,3,4,5,6,7,8,9]
Class2 = [0,1,2,3,4,5,6,7,8,9]
Class3 = [0,1,2,3,4,5,6,7,8,9]
Class4 = [0,1,2,3,4,5,6,7,8,9]
Class5 = [0,1,2,3,4,5,6,7,8,9]
Class6 = [0,1,2,3,4,5,6,7,8,9]
for i in Class1:
for j in Class2:
for k in Class3:
for l in Class4:
for m in Class5:
for n in Class6:
print (i,j,k,l,m,n)
So I want it to output lets say 895 and not 000895. It does that until it reaches 100000, but that’s logical.
Advertisement
Answer
Replace:
print (i,j,k,l,m,n)
By:
print (100000*i+10000*j+1000*k+100*l+10*m+n)