How can I create a brute-force method using the alphabet

I want to create a bruteforcing method using the alphabet.

For example :

x = input("What is your password ?")
length = len(x)

Then the program will check every single combination alphabettically like:

aa,ab,ac,ad and so on.

I have tried one method like:

for c in printable:
    r = c
    status = r
    for c in printable:
        r = (f"{status}{c}")

And this method breaks in the 3rd loop.

Is there a way I can do this?

>Solution :

you can use itertools module of python.

import itertools
import string

length = N

for combinaison in itertools.product(string.ascii_lowercase, repeat=length):
    print(''.join(combinaison ))

Leave a Reply