0

Codecoach password validation python 3

Hello, I have a problem with the last of 13 code checks of the password validator. I've already tried one change (see comments in the code) to have 2 and only two symbols. But with the changes I failed 3 checks instead of 1. I would appreciate your help! Thanks https://code.sololearn.com/cKXTtGibU69P/?ref=app

17th Apr 2020, 10:12 AM
Thorsten Mielke
Thorsten Mielke - avatar
19 Answers
+ 4
Hmm cool that it worked but i get where youre coming from. Heres what works in pyscripter for me: symRegex = re.compile(([!@#$%^&*]{2})+) '!' doesnt pass '!%' passes
17th Apr 2020, 3:30 PM
Slick
Slick - avatar
+ 4
password validation sololearn solution Python https://code.sololearn.com/cvm7w6k0oYUt/?ref=app
21st Oct 2020, 12:35 PM
Khushi Patel
Khushi Patel - avatar
+ 2
Try creating a seperate regex for each check. It become more simple when you, for example, make a numberRegex to check if theres at least one number, make a password length regex to make sure its long enough, ect. Then just create a "check" function that has ALL regex checks inside and have the input pass as the parameter
17th Apr 2020, 10:58 AM
Slick
Slick - avatar
+ 2
Thanks for the help, with your first comment, I did not understand what you mean, but now I think I get it and try to adapt the code👍
17th Apr 2020, 11:06 AM
Thorsten Mielke
Thorsten Mielke - avatar
+ 2
Slick thanks for your help. Changed it and I completed the challenge. But I'm not sure if the description of the problem fits the solution. My new code, as I understand it, only demands 1 symbol and one number instead of 2.. https://code.sololearn.com/cKXTtGibU69P/?ref=app
17th Apr 2020, 3:18 PM
Thorsten Mielke
Thorsten Mielke - avatar
+ 1
And it looks like you set up your regex with a raw string. THATS GREAT! But to make a regex: randRegex = re.compile([a-zA-Z]+) See how "re.compile()" was used? This regex matches one or more letter of any case
17th Apr 2020, 11:01 AM
Slick
Slick - avatar
+ 1
Wait...need to do more tests
17th Apr 2020, 3:33 PM
Slick
Slick - avatar
+ 1
Got it. symbolRegex = re.compile(r'''( ([!@#$%^&*])+ ([^!@#$%^&*])* ([!@#$%^&*])+ )''',re.VERBOSE) It just says there will be one or more symbols, then zero or more NONsymbols, then one or more symbols after that
17th Apr 2020, 3:39 PM
Slick
Slick - avatar
+ 1
VERBOSE is used just to structure it as so. It disregards newlines and comments in the regex
17th Apr 2020, 3:41 PM
Slick
Slick - avatar
0
Awesome, just shoot me a message if anything. Good luck
17th Apr 2020, 11:07 AM
Slick
Slick - avatar