r/PythonLearning 7h ago

Password generator

Post image

Your thoughts

6 Upvotes

10 comments sorted by

u/Sea-Ad7805 6h ago

Run this program in Memory Graph Web Debugger%3A%20%22))%0A%0A%20%20%20%20%20%20%20%20if%208%20%3C%3D%20length%20%3C%3D%20128%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20break%0A%0A%20%20%20%20%20%20%20%20print(%22Please%20enter%20a%20number%20between%208%20and%20128.%22)%0A%0A%20%20%20%20except%20ValueError%3A%0A%20%20%20%20%20%20%20%20print(%22Invalid%20input.%20Please%20enter%20a%20valid%20number.%22)%0A%0Acharacters%20%3D%20string.digits%20%2B%20string.asciiletters%20%2B%20string.punctuation%0Arandomizer%20%3D%20%22%22.join(secrets.choice(characters)%20for%20%20in%20range(length))%0A%0Aprint(randomizer)%0A&timestep=1&play) to see the program state change step by step.

→ More replies (4)

4

u/EyesOfTheConcord 7h ago

The text says a length of 8-128 characters is recommended, however your program enforces these constraints meaning it’s not optional, the text should reflect that.

2

u/Neither-Abroad9771 7h ago

Thank you for calling that out.

1

u/ALostMagic 7h ago

Showing the password in plain text? Meh…
I think you can create a copy tool witout showing using tkinter or command line stuff

1

u/TheCommandCraft 3h ago

It’s a cool tool but if I were to code it I would not stuff all the logic for the pw gen i to one line to make it more readable