So to start this off, this is not the complete program. I am working on a bank management system and just ran into this problem. I'm trying to make the customer type in their login ID and password and it checks the first file after that the code will open another file that checks which the first element is the same as the login ID then print out customer account type and balance. The text file example is at the bottom and I have no idea why my code run through the first loop but not the second.
def LCustomerAccount():
EnteredID = str(input("========== Please Type in Your Account ID:"))
EnteredPassword = str(input("========== Please Type in Your Password:"))
B = open("Customerlogin.txt", "r")
G = open("system.txt", "a ")
Account_NumberList = []
for line in B.readlines():
id, pw = line.strip().split("|", 1)
if (EnteredID == id) and (EnteredPassword == pw):
print("========== Login Successfull============")
print("========== Welcome User============")
Account_NumberList.append(EnteredID)
B.close()
break
else:
print("Wrong Account Number/password")
menu()
for line in G.readlines():
idc,at,balance= line.strip().split("|",2)
if (idc == Account_NumberList):
print("Your Account Type:", at)
print("Your Account Balance:",balance)
print("========== (Option 1). Deposit an amount from your account ============")
print("========== (Option 2). Withdraw an amount from your account============")
print("========== (Option 3). Change Your Account Password ============")
print("========== (Option 4). Log Out ============")
EnterOption = int(input("==========Please Enter Your Option"))
Customerlogin.txt
020403100865|3088
System.txt
020403100865|saving|1000|Lee|3088|00001|200
CodePudding user response:
I think this is suffice if you do not modify the txt file:
G = open("system.txt", "r")