0
Password validation
str=input() count=0 count_1=0 if len(str) >= 7: h=['!','@','#','
#x27;,'%','&','*'] for i in h: if i in str: count+=1 for i in str: try: z=int(i) count_1+=1 except: pass if count >= 2 and count_1 >= 2: print('Strong') else: print('Weak') else: print('Weak') What's wrong I am not able to pass 10,11 test cases ,and they are hidden so I can't see the output error, can any one help out. https://www.sololearn.com/coach/76?ref=app8 Antworten
+ 3
Here is the code of block I've changed.
#Instead of:
for i in h:
if i in str:
count+=1
#That should be:
for i in str:
if i in h:
count+=1
- - - - - - - - - - - - -
The reason is the first one (above code in this comment) iterates the symbol list instead if the input or the password. That is why if "@" for example is already in the input, it does not count others anymore, in other words, it does not count the duplicates.
If you have more questions or confusions, feel free to ask to make myself clear.
If this is still wrong please update me cause I cant see the code coach. Thanks!
+ 1
It solved ,but what's wrong with my block of code
0
Ok wait, I'll make a code visualization.
0
You're interviewing to join a security team. They want to see you build a password evaluator for your technical interview to validate the input.
Task:
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'.
Input Format:
A string representing the password to evaluate.
Output Format:
A string that says 'Strong' if the input meets the requirements, or 'Weak', if not.
Sample Input:
Hello@$World19
Sample Output:
Strong
0
My question is ,as per this question ,can we have duplicate symbols. or we need atleast two different symbols.
0
Yes, even if it is the same symbol it still counts for example:
####!@
this is considered as 6 symbols
0
Ok