编写登录接口,输入用户名密码,认证成功后显示欢迎界面,输错三次后锁定(1.超过三次直接锁定待实现 2.锁定后只能尝试一次)

 
  
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:YanceChan
#作业1:编写登录接口,输入用户名密码,认证成功后显示欢迎界面,输错三次后锁定
username = "bruce"
password = "bruce123"
counter = 0
for i in range(10):
    if counter < 3:
        username_input = input("username:")
        password_input = input("password:")
        if username_input == username and password_input == password:
            print("Welcome to login!")
            break
        else:
            print("Invalid username or password!")
            counter += 1
    else:
        print("Too many attemps! System Locked!")
        break
   


你可能感兴趣的:(编写登录接口,输入用户名密码,认证成功后显示欢迎界面,输错三次后锁定(1.超过三次直接锁定待实现 2.锁定后只能尝试一次))