I'm struggling with my password rater program. How can i make sure that when i insert a password, my program returns the password strength. When i run this program it says that password_strength is stored at .....) is the return that i call at the end of my program wrong?
print ("Welcome to this password rater program")
print ("Your password needs to have a minimum of 6 characters with a maximum of 20 characters.")
print ("Your password can contain lowercase and uppercase characters, numbers and special characters")
print("")
password = input("Please insert your password: ")
def check_len(password):
l = len(password)
if 6 < l < 20:
x = check_char(password, l)
else:
x = 0
return x
def check_char(password, l):
for i in range(l):
ascii = ord(password[i])
num = 0
upper = 0
symbols = 0
lower = 0
space = 0
if 96 < ascii < 123:
lower = 15
elif 47 < ascii < 58:
num = 25
elif 64 < ascii < 91:
upper = 25
elif ascii == 32:
space = 30
else:
symbols = 25
total = ((lower + num + upper + space + symbols) * len(password))
return total
def password_strength(total):
if total >= 1000:
print("Your chosen password is Very strong")
elif 700 < total < 999:
print("Your chosen password is strong")
elif 500 < total < 699:
print("your chosen password is medium")
elif total <= 500:
print("Your chosen password is weak")
return total
strength = check_len(password)
print(password_strength(strength))