Again. I can't find the bug 👇😔 pasword validation | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 5

Again. I can't find the bug 👇😔 pasword validation

cl = ['!', '@', '#', '

#x27;, '%', '&', '*'] num = ["1","2","3","4","5","6","7","8","9","0" ] ab = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] pw = input() m = 0 n = 0 abc = 0 for i in pw : if i in cl: m += 1 elif i in num : n += 1 elif i in ab : abc += 1 pr = True kr = True if abc >= 7 : pr = False kr = False if m < 2 : pr = True if n<2 : kr = True if pr or kr : print("Weak") if not pr and not kr : print("Strong")

9th Jul 2021, 12:41 PM
UnTentetive
19 ответов
+ 8
Yes, that's what I'm trying to explain: By "characters" they don't mean number of of alphabetic characters. I think they mean total length of the string
9th Jul 2021, 1:24 PM
Lisa
Lisa - avatar
+ 6
Is it the code coach task? I looked at the instruction text. Maybe min. 7 characters does not mean 7 alphabetic characters but rather a total length of 7?
9th Jul 2021, 12:56 PM
Lisa
Lisa - avatar
+ 6
Great 👍
9th Jul 2021, 1:27 PM
Lisa
Lisa - avatar
+ 5
Amit Ranjan Sahoo Here's a one-liner possibility: print(("Weak", "Strong")[len(k := input()) > 7 and sum(x.isdigit() for x in k) > 1 and sum(x in "!@#$%&*" for x in k) > 1]) # Hope this helps
10th Jul 2021, 4:28 AM
Calvin Thomas
Calvin Thomas - avatar
+ 4
Can you please but your code in a playground script and then link it here?
9th Jul 2021, 12:46 PM
Lisa
Lisa - avatar
9th Jul 2021, 12:48 PM
UnTentetive
+ 4
Lisa Yes, i did that befor But now i tried all the charecter of my keyboard 👇👇
9th Jul 2021, 1:11 PM
UnTentetive
+ 2
Lisa Yes its cod coach task. Oooo, i listed alphabets🙁
9th Jul 2021, 12:59 PM
UnTentetive
+ 2
I just tried the task: It seems it is not required that the pw has 7 abc... It's enough if len(pw) >=7
9th Jul 2021, 1:09 PM
Lisa
Lisa - avatar
9th Jul 2021, 1:13 PM
UnTentetive
+ 2
I would advise you to use regex for this problem.
9th Jul 2021, 3:29 PM
Pawel Zabinski
Pawel Zabinski - avatar
+ 1
What I meant is the following: pw = "12abc*** should be strong, too, because len(pw) >= 7 although it only has abc as alphabetic characters
9th Jul 2021, 1:18 PM
Lisa
Lisa - avatar
+ 1
Lisa Hmm, i tried this ,but anathor bug obtained 👇👇 if len(pw) >14 And if len(pw) != 14 But it is not fully satisfy.
9th Jul 2021, 1:20 PM
UnTentetive
+ 1
Lisa In Pasword- 12abc*** the charecters are only 3(a,b,c)
9th Jul 2021, 1:22 PM
UnTentetive
+ 1
Lisa , Here "*" is a special charecter not only charecter.
9th Jul 2021, 1:23 PM
UnTentetive
+ 1
Lisa Yaaa, i tried and get succes 😀❤️. Thank you very much 😄
9th Jul 2021, 1:26 PM
UnTentetive
+ 1
Calvin Thomas Wow, you are pro-coder 😀👌🙏
10th Jul 2021, 4:34 AM
UnTentetive
+ 1
You are just counting alphabets that is greater than or equal to 7. It must satisfy all 3 conditions properly to say it as strong else it is evaluated as weak. Kindly make these changes 😀
10th Jul 2021, 1:37 PM
nithin.k.s
nithin.k.s - avatar
0
You should probably considerate learning about regular expressions, it can make your life easier ;)
10th Jul 2021, 3:12 PM
6hpxq9
6hpxq9 - avatar