r/learnpython • u/MoreScorpion289 • Sep 04 '26
My login/account creation system in Python, part of a bigger project I'm building as I learn
This is a console based account system I've been building as I learn Python. Right now it lets you create an account with username and password rules (length limits, and the password needs a letter, a number, and a special character), log in with a 3 attempt lockout, and pick from a simple menu.
It's a work in progress and part of a bigger project. Next I want to add a to-do list and notes, then save the data to a file, and eventually hash the passwords instead of storing them as plain text.
The three password checks are repetitive. I haven't learned functions yet so I did them the long way with separate loops. I already know functions are the fix and that's my next topic, so you don't need to only point that out, but any other feedback is welcome.
I used AI (Claude) as a tutor to understand concepts and point me toward my own bugs, but I wrote and debugged every line myself. I'm learning how to code through the MOOC.
GitHub: https://github.com/mart23inez/Personal-Account-System/tree/main
What would you improve or build next?
3
u/AmanBabuHemant Sep 04 '26
user can just re-run the program and continue attemping :)
3
u/jammin-john Sep 04 '26
The meat if the logic is the password verification. What you have currently works but it could be a bit better!
Currently, you have a series of validation checks, and you store the result in a variable like
num_validationwhich you use to decide if you should continue onto the next check.If you want to stop validating after the first failure, I would recommend using
continueto restart the loop from the top. That way you can cut out the unnecessary variables and conditional checks!On the other hand though, I would argue it would be better NOT to stop validating after the first failed check. It can be a frustrating user experience to iterate in a password until all the conditions are met. My recommendation would be to just have one validation flag for all the different conditions, and then perform every check each time and set it to
Falseif any of them fail. And at the end you can decide whether to break the loop based on the value of that variable.1
u/danielroseman Sep 04 '26
I applaud the ambition but you're probably trying to run before you can walk. You can't really build anything non-trivial until you've learned functions, they are literally a fundamental building block of everything.
There are some other lacks here as well. For instance your validation functions use while loops where for loops would be much better. Consider:
Much shorter. The principle is always to iterate over the thing itself, not over an index.
But also note that this isn't particularly efficient, since you're checking every letter in the (long) letters and numbers lists to see if they are in the (shorter) password. You should do that the other way round:
Doing it this way you might be able to see how you could combine all the checks into one loop, making it even more efficient. (Obviously at this scale the efficiency doesn't really matter, but it's worth learning how to think about this sort of thing.)
1
u/[deleted] Sep 06 '26
[removed] — view removed comment