如何检查密码中的每个字母是否是允许字符列表的一部分

时间:2017-09-18 10:44:10

标签: python

我正在编写一个代码,我想检查密码中的字母是否是允许字母列表的一部分。  这是我正在使用的代码:

letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L''M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9','!','$','%','^','&','*','(',')','-','_','=','+']
passlist = list(password)
print(passlist)
for i in range(len(passlist)):
    on = False
    print(passlist[i])
    for x in range(len(letters)):
        print(letters[x])
        a = passlist[i] + letters[x]
        print(a)
        if passlist[i] == letters[x]:
            on == True
    if on == False:
        print('password cannot contain the following character: ',passlist[i])
        go = True
        global go
        return None

如果该字母是允许的字母的一部分,则结果应为真。 但它总是假的。

0 个答案:

没有答案