+ 2

I request you to tell me the right code. And find my error in this code? For all input, I'm getting a "Week" password.

'''Write a program that takes in a string as input and evaluates it as a valid password. The password is valid if it has at a minimum 2 numbers, 2 of the following special characters ('!', '@', '#', '

#x27;, '%', '&', '*'), and a length of at least 7 characters. If the password passes the check, output 'Strong', else output 'Weak'.''' l, u, d, s = 0,0,0,0 a=[] a=[item for item in input().split()] if (len(a)>=7): for i in a: if (i.islower()): l+=1 if (i.isupper()): u+=1 if(i.isdigit()): d+=1 if(i=="@" or i=="#" or i=="
quot; or i=="%" or i=="&" or i=="!" or i=="*"): s+=1 if( l>=1 and u>=1 and d>=2 and s>=2 and l+u+d+s == len(a)): print ("strong") else: print("weak")

7th Jan 2021, 1:53 AM
Kriti Kumari
Kriti Kumari - avatar
5 Respostas
+ 3
Kriti Kumari You don't need to count how many lowercase and uppercase letters are there, you just have to count the number of symbols and digits and its length. And also check your spelling, "strong" should be "Strong" and "weak" should be "Weak" Here's your code: https://code.sololearn.com/cA100a7A2314
7th Jan 2021, 3:00 AM
noteve
noteve - avatar
+ 3
Thanks to reply
7th Jan 2021, 3:02 AM
Kriti Kumari
Kriti Kumari - avatar
+ 2
But for all input, I'm getting a "Week" password
7th Jan 2021, 3:13 AM
Kriti Kumari
Kriti Kumari - avatar
+ 2
Because the input is a list of only one element: # Change a = [item for item in input().split()] # to a = input() Sorry, I didn't notice. Anyway, I've edited your code (in my previous answer).
7th Jan 2021, 3:41 AM
noteve
noteve - avatar
+ 2
thank you so much 😊
7th Jan 2021, 4:29 AM
Kriti Kumari
Kriti Kumari - avatar