+ 2

Little bit help in python just a line of code

pw = input() num = "1234567890" chr = "!@#$%&*" if any(i in num and chr for i in pw)and len(pw) >= 7: print("Strong") else: print("Weak") This checks that if num and chr are in pw i need to check that 2 Of the num and 2 chr are there in pw

13th Jan 2021, 3:51 AM
Yusuf M Hashmi
3 odpowiedzi
+ 2
You could use regex instead
13th Jan 2021, 3:55 AM
Ananiya Jemberu
Ananiya Jemberu - avatar
+ 2
You might also wish to research the count() method as that may assist your approach
13th Jan 2021, 8:00 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
(1) Since the problem needs a specific number of symbols and numbers, you cannot use any as any becomes true even if there is only one number or symbol, instead, use "len" to know the length of the list comprehension that consists of numbers and symbols in the string. (2) You should have if condition inside your list comprehension at after the "for" rather than before the "for" if you want to filter something. (3) You should use "or" inside the list comprehension and not "and" if you want to detect both. https://code.sololearn.com/cDR8tsz8zw1b/?ref=app
13th Jan 2021, 4:10 AM
noteve
noteve - avatar