Python 实现简单的密码判断

passwdList = ("nihao", "nihao1", "nihao2")

valid = False
count = 3
while count > 0:
    input = raw_input("enter password: ")
    # check for valid passwd
    for eachPasswd in passwdList:
        if input == eachPasswd:
            valid = True
            break
    if not valid:
        print "invalid input"
        count -= 1
        continue
    else:
        print 'Password check pass!'
        break

if not valid:
    print 'Password check Fail!'

你可能感兴趣的:(Python)