Sep-21-2021, 09:29 PM
I've been trying to write a script that simply checks the strength of a password but the results aren't satisfactory. I know there are other ways to do it but I want to accomplish the task with the 'for' loop method:
import string def checkPasswordStrength(password=' '): lowy = string.ascii_lowercase uppy = string.ascii_uppercase digity = string.digits puncy = string.punctuation try: if len(password) <= 6: print("Password must be at least 7 characters") finally: for i in password: if i not in lowy: print("At least a lowercase must be included") elif i not in uppy: print("At least an uppercase letter must be included") elif i not in digity: print("At least a number must be included") elif i not in puncy: print("At least a special character must be included") else: print('Now That is a Strong Password!') checkPasswordStrength('Billycash')I get this response:
Output:At least a lowercase must be included
At least an uppercase letter must be included
At least an uppercase letter must be included
At least an uppercase letter must be included
At least an uppercase letter must be included
At least an uppercase letter must be included
At least an uppercase letter must be included
At least an uppercase letter must be included
At least an uppercase letter must be included