New course! Every coder should learn Generative AI!
Try a free lesson0
Can anyone tell where I am going wrong with this password validator? It returns password invalid when it should be correct
6 Answers
+ 3
Orla Lennon But in your code you are just checking numbers and symbols then why it will work on character.
+ 2
It's working fine. Check your input once. I have entered 1234567#&
+ 2
O B Ok might be it's a problem of symbol £ because when I enter Myname7# it work fine.
I think that symbol doesn't has ASCII value.
+ 1
O B I got problem. When I print the symbol I get ?.
To check just print this and see the output.
Console.WriteLine(special[y]);
0
Hmm thank you A J you do seem to be right.
For some reason just using 7 and £ don't seem to work for me but the other number/symbol combinations do! “Myname7£" doesn't work.
0
A J . The code checks that the password has at least one number and one symbol and no spaces. Therefore "Myname7£" should return "password created" not "password invalid" as it currently is.