I want to make a counter such that there are 3 values in a list counting up at different intervals. For example, list [0, 0, 0] should count up like this [0, 0, 1] => [0, 0, 2] => [0,0,3] until there is "999" in each index [999,999,999].
When the list[2] reaches 999, list[1] should go up by 1 and start counting from zero.
This is what I have:
thisList = ["%03d" % x for x in range(1000)] #produces a list of increasing numbers
trueList = []
for i in range(0, len(thisList)):
trueList.append([int(d) for d in str(thisList[i])]) #Divides the list into each of the individual integers
print(trueList)
Any suggestions?
Use itertools.product
:
trueList = list(product(range(1000), repeat=3))