im incrementing a counter that leads to an index of a list
code:
delist = []
i = 1
idx = [0, ..., 10, ..., 100, ..., 1000, ...]
while( i < len(idx)):
if i in range(1, 10):
delist.append("ladybug_cube_00000" + str(idx[i]) + "_0.jpg")
elif i in range(10, 100):
delist.append("ladybug_cube_0000" + str(idx[i]) + "_0.jpg")
elif i in range(100, 1000):
delist.append("ladybug_cube_000" + str(idx[i]) + "_0.jpg")
elif i in range(1000, 10000):
delist.append("ladybug_cube_00" + str(idx[i]) + "_0.jpg")
elif i in range(10000, 100000):
delist.append("ladybug_cube_0" + str(idx[i]) + "_0.jpg")
elif i in range(100000, 1000000):
delist.append("ladybug_cube_" + str(idx[i]) + "_0.jpg")
#this deletes that index from the list
del idx[i]
#this goes an step back so it repeats the loop with the new index's variable.
i = i-1
i= i+1
The issue is that it should store every string into a new index in the list "delist" and every element should have exacly 6 digits after "cube_" and before "_0.jpg", but it is storing an extra 0 before "str(idx[i])".
example output:
delist=["ladybug_cube_000001_0.jpg", "ladybug_cube_000010_0.jpg", "ladybug_cube_000100_0.jpg", "ladybug_cube_001000_0.jpg", "ladybug_cube_010000_0.jpg", "ladybug_cube_100000_0.jpg"]
What I'm getting:
delist=["ladybug_cube_000001_0.jpg", "ladybug_cube_0000010_0.jpg", "ladybug_cube_00000100_0.jpg", "ladybug_cube_000001000_0.jpg", "ladybug_cube_0000010000_0.jpg", "ladybug_cube_00000100000_0.jpg"]
like it won't pass from "range(1, 10)".