+ 2
Checking if an item is in an list
I am trying to help someone with a password validator, but I haven't used Python in a while. I tried making my own validator to understand the process but it won't work How can I check if the password matches any of the special characters? https://code.sololearn.com/cGoHMr16MO3X/?ref=app
1 Réponse
+ 5
Here I wrote a function which will check for special characters.
You need to iterate through each element of the string and check if it is in the list or not.
chars = ["%", "^", "~", "|", "<", ">", "@"]
def passCheck(str):
for c in str:
if c in chars:
print('Special character, ' + c)
else:
print('Alphabet, ' + c)
passCheck("%%%jdjdjdjdj")