I wanted to think about this problem personally But I know there are experienced people here who have great solutions. I'm trying to create a code number generator and I will improve that to includes all letter cases. But my problem is that for example, for an 8-letter string, I have to copy the for loop eight times, and I can not say how many strings I want by setting a number. Now I want to ask if there is a solution that prevents for for duplication in the code and can only be achieved by setting a generate number?
myPass = []
print("Calculate started..")
for a in string.digits:
for b in string.digits:
for c in string.digits:
for d in string.digits:
for e in string.digits:
for f in string.digits:
for g in string.digits:
for h in string.digits:
myPass.append(a + b + c + d + e + f + g + h)
print("Calculate finish..")
For example, I want to have a function that performs the above process by just setting a number. This is how I can adjust the number of strings:
def Generate(lettersCount):
print("Generate for loops for 12 times..") # for e.g.
print("12 letters passwords calculated..") # for e.g.
Generate(12) # 12 for loop's generated..
Any ideas and suggestions are accepted here.