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

7/26/2019 8:16:19 AM

Coder of Cluelessness

2 Answers

New Answer


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")


n=[1,2,3,4,5] a=4 if a in n: print('in') else: print('out')