Question: Hi there, I tried to write a Python program for login to read multiple username and password from a txt file. How do I write
Hi there, I tried to write a Python program for login to read multiple username and password from a txt file. How do I write the code to read the username and password from the second line and third line from a text file? Below is the screenshot from the text file. I also attached my code.

def registeredCustomerLogin(): print(" ***Dear Valued Registered Customer, Please Enter Your Login.*** ") username = input("User ID: ").strip() password = input("Password: ").strip()
for line in open("Registered_Customer_Login.txt","r").readlines(): #Read the lines. loginInfo = line.strip().split() #Split on space, and store the results in a list of two strings. if username == loginInfo[0] and password == loginInfo[1]: print("Login credentials is approved.") registeredCustomerMenu() #Jump to another function. return True print("Login credentials is incorrect. Please enter again.") registeredCustomerLogin() return False
File Edit Format View He aaron aaron123 becky becky123 charles charles 123
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
