While practicing Python, I decided to build a small password checker.
The idea was simple:
If the user enters the correct password, allow access. Otherwise, deny it.
Sounds easy, right?
Well… I managed...Read More
The Bug
My first logic looked something like this:
password = input("Enter password: ")
if password == "admin123" or "password":
print("Access Granted")
else:
print("Access Denied")
I tested a completely different...Read More
Access Denied
But Python still gave me:
Access Granted
😐
What Went Wrong?
The problem was this part:
password == "admin123" or "password"
I was thinking:
"Check whether the password is admin123 OR password."
But Python doesn't interpret it that way.
The string "password" is a non-empty string, and non-empty strings are considered True in a Boolean context.
So the condition...Read More
The Fix
I changed the condition to explicitly compare the variable with both values:
if password == "admin123" or password == "password":
print("Access Granted")
else:
print("Access Denied")
Now the logic...Read More
What I Learned
This tiny bug taught me something important:
Knowing Python syntax isn't enough. You also need to understand how Python evaluates your logic.
A small mistake in a condition can completely change the...Read More
And when we're talking about authentication, logic mistakes can become security problems.
My Takeaway
I'm still learning Python, so I actually like finding these kinds of bugs.
Instead of feeling that an error means I failed, I'm trying to treat every...Read More
One bug at a time.
One concept at a time.
One step closer to becoming a better developer, InshaAllah.
Have you ever written a simple condition that behaved completely differently from what you expected?
I'd love to hear about it. 👇
#Python #Programming #Debugging #CyberSecurity #LearningToCode #PythonBeginner #ProgrammingJourney
Top comments (1)
Writing this was a good reminder that even a small Python bug can teach you something important.
I’m still improving my programming logic step by step, and debugging mistakes like this are becoming part of the learning journey.
InshaAllah, more bugs, more lessons, and better code ahead.
What’s one small coding mistake that taught you a big lesson?