What is error in this password validator program? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is error in this password validator program?

https://code.sololearn.com/cvE9893bOyA0/?ref=app It is a password validator program Password should contain at least 1 special character , 1 digit and should not contain spaces And should be between 5 and 15 digits Sample input: solosolo Output : no Input : $6ydjsksks Output :yes But my program is saying no for second input

16th Jun 2020, 5:49 AM
Prince Yadav
Prince Yadav - avatar
4 Answers
+ 1
Well, the problem in your code that it doesn't check the all letters of the password, it checks only the 1st letter and then returns 0 or 1 so the for loop doesn't last any longer. You did well with the length test function (lv) But with the for loop you I don't think so, because it'll break out the loop right after the 1st iteration, thus, to pass the number test for example; the first letter of the password must be a number. As well there's a problem with the for loop when it checks x because it doesn't return anything if x wasn't 0 and it has the same issue with the number test, it lasts only for one iteration. Generally speaking, you can make your code more simple, I recommend you to start over and I promise it'll be easier ๐Ÿ‘reduce the number of functions and don't use 'not' as much. Good luck
16th Jun 2020, 11:34 PM
Ahmed Jaabari
Ahmed Jaabari - avatar
+ 1
Thanks for solving problem Now my code is working
18th Jun 2020, 2:22 AM
Prince Yadav
Prince Yadav - avatar
0
I've written a similar program checks the validation of a password. To make ur password strong it must have at least two numbers as well as two symbols. It looks ridiculous how I formed the number test though ๐Ÿ˜‚๐Ÿ˜‚ https://code.sololearn.com/cEEyQzYd7xuK/?ref=app
16th Jun 2020, 11:49 PM
Ahmed Jaabari
Ahmed Jaabari - avatar
0
No problem
18th Jun 2020, 8:37 AM
Ahmed Jaabari
Ahmed Jaabari - avatar