小练习2

小练习2_第1张图片

#encoding=utf-8
users=['mengke','songzhao']
passwd=['hello','hello']
administrationinfo={}
time=3
for i in range(len(users)):
    administrationinfo[users[i]]=passwd[i]
notice='''\
usage
(C)reate
(L)login
'''
print notice
while(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

你可能感兴趣的:(python)