Sorry, I am trying to write a code on python 3.2 for password strength check but it looks like I keep getting error somewhere. Whenever my input is #$%$J, is will go into the if input.upper() is true. How do I prevent this from happening? And my score value is not accurate. coding:
password_user = input("Input password : ")
score = 0
if len(password_user) <=5:
print("Password is too short! ")
score = 1
elif password_user == password_user.lower():
print("Bad Password")
score = 1
elif password_user == password_user.upper():
print("Bad Password")
score = 1
else:
while score == 0:
for x in range(33,48):
ascii_str = chr(x)
if password_user.find(ascii_str) >= 0:
score = score + 3
for y in range(97,123):
ascii_lower = chr(y)
if password_user.find(ascii_lower) >= 0:
score = score + 1
for w in range(65,91):
ascii_upper = chr(w)
if password_user.find(ascii_upper) >= 0:
score = score + 2
for z in range(48,58):
ascii_num = chr(z)
if password_user.find(ascii_num) >= 0:
score = score + 2
if score >0 | score <=5:
print("Weak Password")
print(score)
elif score > 5 | score < 7:
print("Medium Password")
print(score)
elif score >= 7:
print("Strong Password")
print(score)