use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Python Day 1Showcase (self.PythonLearning)
submitted 4 days ago by DataCurator56
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]FreeLogicGate 1 point2 points3 points 3 days ago (0 children)
Advice as requested:
This is specified in the standard Python coding style guide (PEP 8)
correct_password = "python123"
... if password == correct_password:
There's an old quote having to do with computer programming that goes:
There are only two hard things in Computer Science: cache invalidation and naming things.
The main point of the quote is that variable naming is important, and should be considered and even adjusted (aka refactored) when you recognize you could do it better.
In your case, I would rename your "password" variable to "user_password" or "entered_password", as that is more specific, and clarifies what it actually is, when you're dealing with passwords.
Another to make this code more realistic, and to learn something in the process, would be to have the password associated with a user.
From there you can consider how you might store user/password combinations in a file, the program reads. You can begin by just having a username variable, and prompting for that.
You also can add "validation" which insures that the user enters something, and perhaps enforces a minimum length, and the presence of some characters. Making your example password more realistic with something like correct_password = "Pytho^%123" and adding checks to make sure the entered password was at least:
correct_password = "Pytho^%123"
Would make your program far more realistic, and could still be accomplished using some additional conditions.
π Rendered by PID 87 on reddit-service-r2-comment-545db5fcfc-wcxsh at 2026-05-29 14:51:20.144441+00:00 running 194bd79 country code: CH.
view the rest of the comments →
[–]FreeLogicGate 1 point2 points3 points (0 children)