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

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?


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 ))

something like this maybe (suppose length of the password is not known):

from itertools import permutations

password = input()

for i in range(1, len(password) + 1):
    for p in permutations(password, i):
        print(p)

for input like 'abc' the output will be:

('a',)
('b',)
('c',)
('a', 'b')
('a', 'c')
('b', 'a')
('b', 'c')
('c', 'a')
('c', 'b')
('a', 'b', 'c')
('a', 'c', 'b')
('b', 'a', 'c')
('b', 'c', 'a')
('c', 'a', 'b')
('c', 'b', 'a')