+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

7/26/2019 8:16:19 AM

çłůěĺęşş čøðêř

2 Answers

New Answer

+4

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

+3

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