I wrote a function that saves all the numbers between two digital groups into a text file, with a step to save some space and time, and I could not figure out how to show the percentage value, so I tried this.
for length in range(int(limit_min), int(limit_max) + 1): percent_quotient = 0 j=0 while j <= (int(length * "9")): while len(str(j)) < length: j = "0" + str(j) percent_quotient+=1 j = int(j) + int(step)
What I tried to do here was to have the program iterate as many times as it usually did, but instead of writing to a file, I just made the percent_quotient variable how many times the iteration repeats, (I called j dummy variable, since it is there only to break the loop, sorry if there is another expression for this.) The second part is the actual work, and I put the counter variable and I divide it by percent_quotient and multiply by 100 to get the percentage.
The problem is that when I tried to make a dictionary from 1 to 8 in length, it actually took a minute to count everything. I guess it will take much longer if I want to make an even larger dictionary.
My question is, is there a better way to do this faster?
Meaty source share