小练习2

来源:互联网 发布:今日头条视频推荐算法 编辑:程序博客网 时间:2024/05/29 19:03

这里写图片描述

#encoding=utf-8users=['mengke','songzhao']passwd=['hello','hello']administrationinfo={}time=3for i in range(len(users)):    administrationinfo[users[i]]=passwd[i]notice='''\usage(C)reate(L)login'''print noticewhile(True):    choice=raw_input("please chose a mode")    if choice=='C':        newuser=raw_input("please input the new name")        for new in users:            if new==newuser:                print "the name is already existed"                break            else:                users.append(newuser)                newpasswd=raw_input("please input the new passwd")                passwd.append(newpasswd)                administrationinfo[newuser]=newpasswd                print "success"                break    elif choice=='L':        loginuser=raw_input("please input your name")        while loginuser not in users:            print "wrong"            time-=1            loginuser=raw_input("please try again")            if time <= 0:                print "you have already tried three times please try in 10min"                break        loginpasswd=raw_input("please input your passwd")        for i in range(3):            if administrationinfo[loginuser]==loginpasswd:                print  "welcome"                break            else:                time-=1                loginpasswd=raw_input("try again")                time-=1            if time <= 0:                    print "you have already tried three times please try in 10min"                    break
原创粉丝点击