while,for,if輸入帳號密碼判斷
AccountNumber1 = [] password1 = [] flag = True while flag: num = 0 a = 1 print('-----------這是個歡迎介面---------------') print(''' 1、註冊帳號 2、登陸帳號 3、更改密碼 ''') num=input() if num==1: while a<2: AccountNumber=input('請您註冊帳號') if AccountNumber1.count(AccountNumber)==0: AccountNumber1.append(AccountNumber) print('您的帳號是{}'.format(AccountNumber)) else: print('{}這個帳號已經被註冊過咯!請進行其他操作!'.format(AccountNumber)) break password=input('請註冊您的密碼') if password1.count(password)==0: # print(password1.count(password1)) password1.append(password) print('您的密碼是{}'.format(password)) a+=1 if num==2: x=-1 EnterAccount=input('請輸入您的帳號') Enterpassword=input ('請輸入您的密碼') for i in AccountNumber1: x+=1 if i==EnterAccount: if password1[x]==Enterpassword: print('登陸成功!') flag = False break else: print("密碼不正確") else: print('帳號不存在') else: print('帳號不存在') if num == 3: x = -1 for i in AccountNumber1: x += 1 AccountNumber = input('請輸入您的帳號') OldPassword = input('請輸入您的舊密碼') if i == AccountNumber: if password1[x] == OldPassword: NewPassword=input('輸入您的新密碼') password1[x]=NewPassword print('修改完畢!') flag = False break else: print("密碼錯誤,請重新輸入舊密碼") else: print('帳號不存在或錯誤') else: print('帳號不存在')