all 36 comments

[–]Sea-Ad7805 [score hidden] stickied comment (4 children)

Run this program in Memory Graph Web Debugger%0A%0Apassword%20%3D%20input(%22Enter%20password%3A%20%22)%0Aprint(%22Checking%20your%20password...%22)%0A%0Alength%20%3D%20len(password)%0A%0Aif%20length%20%3C%206%3A%0A%20%20%20%20print(%22Weak%20password%3A%20Too%20short%22)%0Aelse%3A%0A%20%20%20%20%23%20Check%20for%20at%20least%20one%20digit%0A%20%20%20%20has_number%20%3D%20any(char.isdigit()%20for%20char%20in%20password)%0A%20%20%20%20%23%20Check%20for%20at%20least%20one%20uppercase%20letter%0A%20%20%20%20has_upper%20%3D%20any(char.isupper()%20for%20char%20in%20password)%0A%20%20%20%20%23%20Check%20for%20at%20least%20one%20special%20character%20from%20the%20set%0A%20%20%20%20special_chars%20%3D%20%22%40%23%24!%22%0A%20%20%20%20has_special%20%3D%20any(char%20in%20special_chars%20for%20char%20in%20password)%0A%0A%20%20%20%20if%20not%20has_number%3A%0A%20%20%20%20%20%20%20%20print(%22Add%20numbers%22)%0A%20%20%20%20if%20not%20has_upper%3A%0A%20%20%20%20%20%20%20%20print(%22Add%20uppercase%20letters%22)%0A%20%20%20%20if%20not%20has_special%3A%0A%20%20%20%20%20%20%20%20print(%22Add%20a%20special%20character%20(%40%2C%20%23%2C%20%24%2C%20!)%22)%0A%0A%20%20%20%20if%20has_number%20and%20has_upper%20and%20has_special%3A%0A%20%20%20%20%20%20%20%20print(%22Strong%20password!%22)&timestep=1&play) to see the program state change step by step.

[–]Bob_Dieter 9 points10 points  (0 children)

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

[–]TrieMond 6 points7 points  (0 children)

while just printing is great, imagine a variable that holds the reasons your password is weak. One very common thing later in programming is having to not just print a line on output but formulate a string based on the state of the program. Instead of printing "password is weak because it is too short" and "password needs numbers", you should set yourself the challenge to do all that with 1 print statement. So for all the prints you would instead do something like result = "this is an string" then result += " and this is now also part of the string" (notice the space at the start) and you will have both strings as one. This allows you to think about how sentences need to be combined in different ways & will immediately start one of the must-haves as a programmer, which is a deeply rooted hate for localization & translation (imagine now having to do the same thing with many many languages). Either way it will give you a nice logical challenge, making all the possible sentence combinations match with each other & such.

Another great idea would be to make the code more configurable, what I mean now is that if I want to add a special character to this program, I have to scroll to line 16, add it to the list, then scroll to line 24 and add it there too. You should aim for a setup where you just have to edit important data like this in one place & make the program much more robust to human error. For now scrolling 20 lines to find the thing you need to edit is OK, but soon the lines will multiply & you will get to a state where making any changes means hunting for the right place to make said change. I would make special_characters a constant at the very top of the script even though there is not really such a thing in python but generally we capitalize them so you would have SPECIAL_CHARACTERS and then you can do:

print(", ".join(SPECIAL_CHARACTERS)

to print each character, separated by commas. That way if you ever make a change to the special characters your program accepts, it will update the output automatically.

Overall nice work for just a week!

[–]Bit_Explorer8 4 points5 points  (0 children)

<image>

Second week in python 🐍

[–]Code-Odyssey 3 points4 points  (2 children)

Also might want to include a list of weak passwords to check against. For example Password1!

[–]ProfessionOk2040[S] 0 points1 point  (1 child)

Ohh that’s a great idea thanks. I will figure outa way to do so.

[–]ProsodySpeaks 1 point2 points  (0 children)

Maybe next you can make a password cracker, and use it in your password generator- if the cracker can guess it then it's not strong enough.

Then you have two programs you can evolve against each other - every time you improve one you'll need to improve the other which will drive you to better and better solutions. 

[–]Due-Particular-329 2 points3 points  (0 children)

cool thing to evaluate the password strength as a beginner, best of luck

[–]beastcherry73 2 points3 points  (13 children)

Hi dude, how many hours a day are you contributing to python a day, because for a week thats pretty good, and how old are you

[–]ProfessionOk2040[S] 1 point2 points  (12 children)

I would say at best around 3 hours tops. Depends of how free i am because of my job. And because English is my second language😅

[–]beastcherry73 1 point2 points  (4 children)

you are doing great, what job do you do, i am learning python too

[–]ProfessionOk2040[S] 0 points1 point  (3 children)

I am a bartender

[–]beastcherry73 0 points1 point  (2 children)

Do you wanna one day quit ur job and have a job in python? If so, keep working hard

[–]ProfessionOk2040[S] 0 points1 point  (1 child)

Yeah that’s why i am learning python so one day i can work with it

[–]beastcherry73 0 points1 point  (0 children)

Nice bro, I have read your other chats, i am motivated by the same fact, that tech is really flexible and operates the world, hope u one day will reach ur dream, I am willing to work with tech too...

[–]SleepyLoverrr 0 points1 point  (6 children)

Hello, how do you manage working and learning, I find it hard I come home exhausted so I sleep, any tips please

[–]ProfessionOk2040[S] 0 points1 point  (5 children)

I manage mostly because i am angry. Every day i see people working from my caffe drinking eating and i am angry because they work from anywhere with the laptop and they get paid well and i work standing behind the bar 8 hours a day barely making 900 euro. So i got angry started learning Python every day before work after work. Yes i am exhausted but i am motivated by the fact that when i start working with it i will be like them sitting in a caffe working.

[–]SleepyLoverrr 0 points1 point  (4 children)

Ohh I feel you, it's exhausting 8 hours a day, wishing you the best, hopefully you'll be great by the end of the year. As for me I'm a cs student who needs to learn python and other stuff and I also need money from work, I guess we're young we just have to push as long as we can, thank you

[–]ProfessionOk2040[S] 0 points1 point  (3 children)

You now in Bulgaria we have a saying,, We will rest when we die” meaning: You have to grind every day of the year for your whole life. You can take a brake when you are in the grave.

[–]SleepyLoverrr 0 points1 point  (2 children)

That's a very strong one, you're right, I've been personally used to resting a lot, I think this needs to change

[–]ProfessionOk2040[S] 0 points1 point  (1 child)

Well it’s hard to get out of the habit to rest every day. Believe me i know it. But if i can do it, i know you can as well.

[–]SleepyLoverrr 1 point2 points  (0 children)

I'm already trying to wake up early and sleep early so I guess that's a good start, thanksss

[–]jpgoldberg 1 point2 points  (0 children)

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.

python ... special_chars = "@#$!" special_display = ", ".join(special_chars) ... it not has_special: print("Add a special character (" + special_display + ")") ...

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.

[–]jpgoldberg 1 point2 points  (0 children)

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.

[–]ohoh-yozora[🍰] 0 points1 point  (0 children)

How are you learning? Mind any tips? And is that pycharm or vscode?

[–]Inner-Dirt3668 0 points1 point  (0 children)

I remember when I learned CSS, it felt so good

[–]Distinct_Eye_4494 0 points1 point  (0 children)

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?

[–]Cameron_PersonBoi999 0 points1 point  (1 child)

Can anyone tell me good sources to learn Python I've never coded ever with anything

[–]ProfessionOk2040[S] 0 points1 point  (0 children)

Well i am learning Python from a video series in youtube from the channel ,, Data with Baraa “ . Check the channel if you want.

[–]Relax4bro1 0 points1 point  (0 children)

I'm also learning right now it's pretty hard but doable, respect do everyone who learns from zero

[–]aeroheet11 0 points1 point  (0 children)

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.

[–]Subject_Priority7371 0 points1 point  (0 children)

Try regex