Have you ever set your password to "1234" because it was "temporary"? 🙋 Same. Spoiler: I never changed it. So when I learned the while loop in Python, the first thing I built was the password validator my past self desperately needed — one that doesn't let you off the hook so easily: What this actually taught me: 🔁 while keeps running as long as the condition holds ⏭️ continue = "nope, not this one — next attempt" 🛑 break = "done, we're leaving" 🤯 the else on a while only runs if you never hit break — this one genuinely broke my brain the first time That last one? Almost nobody mentions it in beginner tutorials. And it's honestly one of the most elegant things in Python. #Python #LearningInPublic #Programming #Code
For learning next step would be to read in to the random moudule.Let the input decide length, and type of password.Then generate a password for the correct type.E.g. lower caps only, mixed caps, mixed caps + numbers, mixed caps + special chars.Hint there is a ascii module that define some of these constants.
To learn Python → ✅ excellent. For a real system → need getpass + robust validations + confirmation. My two cents
"the else on a while only runs if you never hit break" Well, would you look at that! Nice to see the usually terse, blunt python be so fluid and elegant for a change! Thanks for making my mind go 🤯today, Víctor Ángel de la Cruz Torres!
Is this satire?
A history about constrains, that it's not so related to the post, but came into my mind while reading it: Many years ago I was trying to set up a digital account in bank, and they asked me for a very weird pattern: - 6 Digits maximum. - No special characters. - No spaces. - No numer in sequences. (1234) - No equal number repeated on sequence. (12234) Well, I believe such restrictions will actually make a brute force attack easier, because you can take out a lot of possible passwords from the try outs.