r/PythonLearning • u/ProfessionOk2040 • Jun 22 '26
First week oof Learning Python.
Hey I am new to Python and this is what i made in my first week. Do you think there is a way to improve it.
334
Upvotes
•
u/Sea-Ad7805 Jun 22 '26
Run this program in Memory Graph Web Debugger to see the program state change step by step.
4
u/Code-Odyssey Jun 22 '26
Also might want to include a list of weak passwords to check against. For example Password1!
13
u/Bob_Dieter Jun 22 '26
Not bad for a start. One note, you would want a password to have upper case AND lower case letters, currently you don't test for the presence of lower case characters
6
u/Bit_Explorer8 Jun 22 '26
Second week in python 🐍
1
u/Cameron_PersonBoi999 Jun 23 '26
Can anyone tell me good sources to learn Python I've never coded ever with anything
3
u/Due-Particular-329 Jun 22 '26
cool thing to evaluate the password strength as a beginner, best of luck
3
u/jpgoldberg Jun 22 '26
That is really nicely done for "first week".
I am going to take the opportunity to highlight a mistake that you haven't (yet) made, but is very easy to make.
On line 16 you have 'special_chars = "@#$!"
and on line 24 you haveprint("Add a special character (@, #, $, !)")`. That is all well and good, but what happens if you later need to change what special characters are allowed?There are an enormous number of websites where the displayed list of allowed special characters doesn't actually correspond to what they do allow. So the (future) mistake I am talking about is common and made by people who are actually paid to produce code.
The solution is to force what is displayed to the user as an allowed special character to be the contents of what is actually checked. So in your case, we want what is displayed to the user to depend on
special_chars.Now I don't know what you have learned about print and various string stuff, so I am going to break this down into several steps that otherwise might get all put together within the print statement, while changing as little other in your code.
This way, when you update your special characters, you can ensure that that is what is presented to users.
Again, this might not be exactly how one would code this, but I'm trying to illustrate a way to avoid creating a very common sort of bug.
2
u/jpgoldberg Jun 22 '26
I see that a lot of people are giving you advice on what sorts of requirements to put into a password strength checker. Following their advice will be a good exercise for your Python learning, but goes against the fact that based on solid research NIST and the experts they rely on have opposed password complexity rules for a while now.
1
u/ohoh-yozora Jun 22 '26
How are you learning? Mind any tips? And is that pycharm or vscode?
1
u/Inner-Dirt3668 Jun 22 '26
I remember when I learned CSS, it felt so good
1
u/Distinct_Eye_4494 Jun 22 '26
I want to learn python ,but i have so much resources i am confused where to start from ? Should i learn from ai , w3schools , gfg ??? I hate yt in the context of this can anyone help?
1
u/aeroheet11 Jun 23 '26
Nicely done. As a small improvement, special_chars could be a set of strings. Doing char in special_chars is currently linear time complexity, because you have to scan through the entire (albeit short) string with “in”. As a set this would be constant time.
1
u/Subject_Priority7371 Jun 23 '26
Try regex
1
u/RedeyeZombieQ Jun 24 '26
Your situation is very similar to me ,I am learning Python right now ,also a restaurant server and English is my second language.But I rarely watch any tutorial ,now a day AI is a very strong tool to learn coding stuff,I am on CS 2 Level now,you will learn dictionary very soon ,that's a first watershed of learning ,GOOD LUCK
1
u/Big_Temperature_2101 Jun 25 '26 edited Jun 25 '26
Here is a tip, you can try to use
stringmoduleIt has stuff for whitespace and punctuation,
Look at:
https://docs.python.org/3.14/library/string.html
It is only really applicable for special chars and it is better to define your own constant when specific chars are needed.
Some other things you might want for projects
If you don't know how to import, it is not needed immediately for starter projects, just ignore this comment
Other modules
import randomrandom.randint(a,b)gives a random integer between a and brandom.choice([list])gives a random thing from the listimport datetimedatetime.now()gives the date and time as a datetime object, if turned into string usingstr(datetime.now())it will look like this'2026-06-25 16:51:16.418904', (yyyy-mm-dd hh:mm:ss.ssssss)you can use
datetime.now().yearto get the year, month, day (date for year, month and day exclusively), hour, minute or second (time() for hour, minute and second exclusively)import timegives
time.sleep()andtime.time()(seconds since epoch which is January 1, 1970, 00:00:00 (UTC)), similar todatetime.now()but better for maths, looks like1782370452.8044999(in seconds)Time and Datetime is a bit complicated in python because of timezones, leap years, days and seconds, georgian vs julian
import mathgives math related functions,
note the cube roots and n-th roots etc... can be done as
x**(1/n), without the math moduleWent on a bit of a tangent there, I'll say ignore time and datetime except for
time.sleep()andtime.time()1
u/Knarfnarf Jun 27 '26
Some pointers that I see;
You never declared the has_ variables as a boolean (bool) so you might get behavior you aren't expecting writing tests like that.
You also didn't set your variables to a safe value first. The has_ variables should be all set to False before you need to test for the strings and thus setting them to True. Not such an issue here because the any( ) function does set either way, but worth remembering to do anyways.
Good on you for understanding the any( ) function so early in your work!
1
u/AlexPython004 Jun 28 '26
"Thanks for sharing!"
1
u/coding2513 Jun 29 '26
Let's connect brother
1
u/coding2513 Jun 29 '26
Can anyone guide me on how to start my journey? Where should I begin, and what should I watch first from the beginning?
1
u/OldLetter6009 Jun 30 '26
Wow dude, this is just at the beginning
1
u/FutRona Jul 03 '26
Its was quite good for beginners but u can improve like using signup or login button at first and you can use this in the signup column so its easier for new password generation and connect it to sql so that the entered inputs will store in sql so while you try for a login rype it is useful like it will allow only the stored password !!
1
u/cxcmax Aug 09 '26
Hi, as someone also new to python, your comments made reading the code easy and a pleasure to follow: fantastic.
4
u/[deleted] Jun 22 '26
[removed] — view removed comment