Multi-user password (after the failure of unrealized locked)

Log in to write interfaces

Basic requirements ::

* Let the user to enter a user name and password

* After successful authentication display a welcome message

* After unsuccessful attempts to enter an error

Upgrade requirements:

* Support for multiple users can log on (store multiple account information via list)

Or locked state when the user tries to log in * 3 authentication fails, quit the program, start again

count = 3

id_list = ['wick','seven','wiki','nina']
password_list = [123,456,789,321]
while count>0:#重复输入三次wick

    id = input('请输入账号:')
    password = int(input('请输入密码:'))
    n =0
    while n<4:

        if id == id_list[n]:
            if password == password_list[n]:
                print('登录成功!')
                break
            else:
                if n == 3:
                    print('登陆失败!')
                    if count == 1:  # 限制账号输入次数
                        print('你的账号已被锁定!')
                        break
                    else:

                        # print('你还可以输入%d次!'% (count-1))
                        print(f'你还可以输入{count-1}次!')
        else:
            if  n ==3:
                print('登录失败')
                if count == 1:  # 限制账号输入次数
                    print('你的账号已被锁定!')
                    break
                else:

                    # print('你还可以输入%d次!'% (count-1))
                    print(f'你还可以输入{count-1}次!')
        n+=1
    count -= 1

Guess you like

Origin www.cnblogs.com/wick2019/p/11402345.html