← Back to all posts
point scoring system

How would I make a code that would check the password for the following and add or subtract the following points :

• the amount of characters is equal to the first amount of points
• capital letters + 5 points
• lower case letters +5 points
• digits(1-9) + 5 points for each one
• special characters(!\$%^&*()_-+=) + 5 points
• only capital letter -5 points
• only lowercase letters -5 points
• only digits -5 points
• only special characters -5
• if the password contains three consecutive letters based on the layout of the UK QWERTY keyboard -5 points for each set of three.

In addition I would also like to know how to generate a random password that follows the point scoring system above and has 8-12 letters.The password would have to be classified as strong to be shared with the user.

• 20+ is strong
• 0 or less is weak
• anything else is medium
EchoCoding (260)

Hello @kiki2005,

I started the program out for you. By using the `len` command in python, it will return the length of the string. From there, simply use other functions such as `.isupper()` and `.islower()`.

``````points = 0 # set the point value to zero

uppers = [x for x in password if x.isupper()] # check for uppercase letters
uppernum = len(uppers) # find the number of uppercase letters

lowers = [x for x in password if x.islower()] # check for lowercase letters
lowernum = len(lowers) # find the number of lowercase letters

. . .

points = points + length + (uppernum * 5) + (lowernum * 5) # add the final point total

Using `if` statements, or logical analysis, can change how the point values are used. Instead of doing `(uppernum * 5)` or `(lowernum * 5)`, you can do `if` . . . `lowernum =+ 5`.

Hope this helped!

kiki2005 (5)

@EchoCoding thank you so much for your help.the explanation on each line really helps me to understand each part of it as well.Thank you

EchoCoding (260)

@kiki2005 Of course! If you have any other questions feel free to ask.

ryanhcode (91)

Have you tried making a program by yourself to solve this? If you have then it’s a lot better to ask about it because you are asking about something that you are having trouble with. What part of this are you getting stuck on?

kiki2005 (5)

@ryanhcode i have tried to do it myself but I am having trouble actually making the point scoring system.I just don't understand where to start or what to include or how to lay it out.I think that it is because there is so much information that it is making it hard for me to process.I was just wondering if anyone could help me really as i am struggling with the whole thing.

Koalaknightmi (1)

how about also if it uses any words in it like hi or hello or hellothere

kiki2005 (5)

@Koalaknightmi I dont mind as long as it does what I have said above and it works