验证用户密码程序

#验证用户密码程序,用户只有三次机会输入密码,如果三次输入错误程序退出,如果输入*则不包含一次机会。
scode='wang'
chance=3
print('您好,请输入密码,以回车键结束:')
while chance:
    ecode=input('请输入密码:')
    if ecode==scode:
        print('欢迎登陆!')
        break
    elif '*'in ecode:
        print('密码中不能带*,您还有',chance,'机会,请重新输入:')
        continue
    else:
        print('密码错误,你还有',chance-1,'次机会')
        if chance==0:
            print('密码输错三次,今日无法登陆')
    chance-=1
原文地址:https://www.cnblogs.com/themost/p/6358870.html