1.需求
编写登陆接口 输入用户名密码 认证成功后显示欢迎信息 输错三次后锁定
2.自己思路
定义user_database 用户输入 if 成功: print welcome!!! else 失败 print 继续输入 用户输入 if 成功: print welcome!!! else 失败 print 继续输入 继续循环
3.代码清单
# coding=utf-8
user_database = [['alex','123']]
count = 0
for i in range(3):
username = input("enter your username: ")
passwd = input("enter your passwd: ")
if [username,passwd] in user_database:
print("welcome")
break
else:
print("again...")
count += 1
if count >2 :
print("myou have try enough...fuck off")
4.运行结果
running successfully

running failed
