Mar-03-2018, 07:42 AM
(This post was last modified: Mar-03-2018, 07:42 AM by RedSkeleton007.)
zfill is the answer:
#!/usr/bin/env python3 #PadLockGuesser.py lockCombo = 1080 #brute force pad lock guesser with while loop: guess = 0 while guess <= lockCombo: #guess += 1#placing the guess incrementor here causes 0 to not be one of the guesses if guess == lockCombo: print("After " + str(guess) + " guesses, the correct combo is " + str(guess)) break else: print(str(guess).zfill(4) + " is not the correct combo. Trying next guess.") guess += 1#placing the guess incrementor here causes the program to stop guessing at 1079 continue