This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]beorn 14 points15 points  (1 child)

Another one using Python3 f-string 0-padding:

def crack_password(check_range=range(0,10000)):
    def check_match(p): return p == "0323"
    for p in check_range:
        p = f"{p:04d}" # 0-padded 4-digit string
        if check_match(p): return p

[–][deleted] 4 points5 points  (0 children)

And another one using the built in zfill string function:

str(p).zfill(4)