print ("Welcome to my Quiz!")
existing = input("Are you an existing user?: ")
if existing.lower == "yes":
print("Enter your credidentials")
username= input("Enter your Username: ")
password= input("Enter your Password: ")
file= open("data.txt", "r")
found=False
for line in file:
account = line.split(",")
if account[0] == username:
password= existing[1]
found=True
file.close()
if found==True:
print("Welcome Back", username ,)
if found==False:
print("Account not found")
else:
existing.lower == "no"
user= input("Enter your first name: ")
year= input("Enter the year you are in: ")
password= input("Enter your password: ")
username=user[:2]+year
writefile=open("data.txt","a")
writefile.write(username + "," + password + "\n")
writefile.close()
print("Your account has been created." "Your username is..", username , "..and your password is", password,)
我試圖做一個測驗,我希望它的工作原理是,如果他們的用戶有一個帳戶,它不會經歷一個新的帳戶的過程。現在,如果我登錄,它仍然要求我的名字等,完全跳過if
和else
命令。跳過如果和其他命令
'existing.lower'應該是'existing.lower()',但除非你有一些嚴重的壓痕問題,這ISN」 t相關。 – chepner
也無關緊要,你永遠不會檢查輸入的密碼是* correct *密碼。 – chepner
您需要縮進從'username ='一直到'print(「Account not found」)的所有內容。因爲'else'語句是第一個'if',所以在頂部 – abccd