0

Password validation challenge

I can't figure out what's wrong with this code for the password validation challenge (if input has 7+ characters, 2+ of the following: !@#$%@* and 2+ numbers print "Strong", otherwise print "Weak"). It only failed 1 of the 13 test cases, and the one it failed is hidden. Help? password = list(input()) specialCharacters = 0 numbers = len(password) while True: if len(password) < 7: print("Weak") break for i in range(len(password)): if password[i] == "!" or "@" or "#" or "

quot; or "%" or "&" or "*": specialCharacters += 1 if specialCharacters < 2: print("Weak") break for i in range(len(password)): try: int(password[i]) except ValueError: numbers -= 1 if numbers < 2: print("Weak") break print("Strong") break

11th May 2020, 2:58 PM
Benjamin Richter
2 ответов
0
You missed to specify "password[i] ==" in front of all special characters except the first one. You can also check with this: if password[i] in ["!", "@", "#", "
quot;, "%", "&", "*"]:
11th May 2020, 3:20 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar
0
Oooh. I had had issues with that type of stuff before but wasn't really sure how to fix it or when it happened. Thanks!
11th May 2020, 3:21 PM
Benjamin Richter