I am trying to make a program where it sorts out numbers in a range and puts them into a list if the digits are in ascending order or stay the same. I have tried this:
numbers1 = []
for count1 in range(2, 3):
for count2 in range(0, 10):
for count3 in range(0, 10):
for count4 in range(0, 10):
for count5 in range(0, 10):
for count6 in range(0, 10):
number = (count1,count2,count3,count4,count5,count6)
if number[5] >= number[4]:
if number[4] >= number[3]:
if number[3] >= number[2]:
if number[2] >= number[1]:
if number[1] >= number[0]:
numbers1.append(number)
print("Done")
input()
numbers2 = []
for count1b in range(3, 8):
for count2b in range(0, 5):
for count3b in range(0, 7):
for count4b in range(0, 4):
for count5b in range(0, 3):
for count6b in range(0, 6):
number = (count1b,count2b,count3b,count4b,count5b,count6b)
if number[5] >= number[4]:
if number[4] >= number[3]:
if number[3] >= number[2]:
if number[2] >= number[1]:
if number[1] >= number[0]:
numbers2.append(number)
print("Done")
but when I run it and type numbers2 into the command prompt it just returns an empty list. numbers1 returns a complete list of numbers from 200000 to 299999 that follow the rule I explained above.
From what I can work out the first part of the code is working but it seems to just skip out the second part.
Anyone know why?
for count1b in range(3, 8), laterfor count5b in range(0, 3)and then you compare the values. How do you expect the max value ofcount5b(2) to be bigger than the minimum value ofcount1b(3)? The result is correct.