0

Test case #8 fails. What did I do wrong? https://code.sololearn.com/cDOO7sW7r61P/?ref=app

6th May 2020, 7:31 PM
Nafis
12 ответов
+ 4
You have to separate special and numeric characters. Otherwise there could be numeric or special without the other. import re pswd = input() special = re.sub ("[!@#\$%&*]", "", pswd) nums = re.sub ("[\d]", "", pswd) if len(pswd) < 7 or len(special) == len(pswd) or len(nums) == len(pswd): print ("Weak") else : print ("Strong")
6th May 2020, 10:32 PM
Manu_1-9-8-5
+ 2
With re, but test 15 does not pass, I couldn't figure why: import re pas = input() if len(pas) >= 7: print('Strong' if re.search(r"[0-9]{2}", pas) and re.search(r"[!@#\$%&*]{2}", pas) else 'Weak') else: print('Weak') Without re, like a noob, passes all tests: num = ['0', '1', '2', '3', '4', '5', '6', '7','8', '9'] spec = ['!', '@', '#', '
#x27;, '%', '&', '*'] pas = input() if len(pas) >= 7: n = 0 s = 0 for l in pas: if l in num: n += 1 if l in spec: s += 1 if s >= 2 and n >=2: print('Strong') else: print('Weak') else: print('Weak')
20th Dec 2021, 6:21 PM
TensorFlow23
+ 1
6th May 2020, 7:32 PM
+ 1
17th Mar 2021, 3:58 PM
Константин Новоселов
+ 1
13th May 2022, 2:29 PM
Андрей Бурвель
0
6th May 2020, 7:36 PM
Nafis
0
No problem post your code so that someone see your code and solve error.
6th May 2020, 7:39 PM
0
This is the correct answer! import re running = True password = input() number = re.compile(r'\d') num = number.findall(password) numb = re.compile(r'\d') n = number.findall(password) special_character = re.compile(r'[^\w\d\s]') spe_char = special_character.findall(password) if len(password) >= 7 and num != [] and spe_char != [] and numb != []: print('Strong') else: print('Weak')
9th Oct 2020, 7:29 AM
Dawit Mekonnen
0
import re _main_ = 'name' password = input() # 'hello @ \$ World19' def check_simbol(passw) -> object: check1 = re.findall(r'[!@#\$%&*]', passw) # find simbols return check1 def check_num(passw) -> object: check2 = 0 for i,s in enumerate(passw): if s.isdigit(): check2 += len(s) # count numbers return check2 if len(password) >= 7 and len(check_simbol(password)) >= 2 and check_num(password) >= 2: print('Strong') else: print('Weak')
1st Sep 2021, 8:50 PM
Johny Bracker
0
Complementing to @Manu_1-9-8-5 solution, since the "pswd = Hello@World#9" must not be Strong. Uncomment the IF to verify. import re #pswd = input() pswd = "Hello@World#9" special = re.sub ("[!@#\$%&*]", "", pswd) nums = re.sub ("[\d]", "", pswd) #if len(pswd) < 7 or abs(len(special)-len(pswd))<2 or abs(len(nums) - len(pswd))<2: if len(pswd) < 7 or len(special)==len(pswd) or len(nums) ==len(pswd): print ("Weak") else : print ("Strong")
21st Jan 2022, 5:32 AM
Antonio Rojas
0
password= input() num = 0 v = 0 L=[] s = ['!', '@', '#', '
#x27;, '%', '&', '*'] for c in password: if(c.isnumeric()): num+=1 L.append(c in s) v= L.count(True) if(num>=2 and v >=2 and len(password)>=7): print("Strong") else: print("Weak")
19th Mar 2022, 7:09 PM
Alex
0