登录三次机会编程

username = "taibai"
password = "123"
i = 0
while i < 3:
    name = input('请输入你的用户名:')
    pwd = input('请输入你的密码:')
    if username == name and password == pwd:
        print("您登录成功")
        break
    else:
        print("登录失败,您还有%d次登录机会" %(2-i))
        if (2-i) == 0:
            result = input("是否还想在试试? Yes")
            if result == "Yes":
                i = 0
                continue
    i += 1
else:print("要不要验你")

 

posted @ 2020-02-20 16:12  小龙a  阅读(181)  评论(0编辑  收藏  举报