r/learnpython 1h ago

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?

1 Upvotes

5 comments sorted by

2

u/AmanBabuHemant 1h ago

log in with a 3 attempt lockout

user can just re-run the program and continue attemping :)

1

u/MoreScorpion289 1h ago

Yes lol temporary for now, real lockout coming soon.

2

u/CoderStudios 1h ago

There is no way to do a “real” lockout, if you control the program and the pc it’s running on its impossible which is why we commonly have login servers not programs.

u/danielroseman 5m ago

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:

        for number in numbers:
            if number in password:
                num_verification = True
                break
        else:
            print("Error: Password must include 1 number, please try again.")

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:

        for character in password:
            if character in numbers:
                num_verification = True
                ...

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.)