This is a text file accountinfo.txt:
Luke TonyHawk123! [email protected]
Cindy JasonVoorhees123! [email protected]
I want to ask the user for their email to print the values (i.e. their username and password) on the left. For example, if the user inputs [email protected], it should return Luke and TonyHawk123.
I've tried using strip and split, but my logic is wrong.
Work I've done so far:
account_file = open("accountinfo.txt")
email_string = account_file.read().strip().split()
while True:
email_account = input("Enter the email linked to your account: \n")
if email_account == "":
continue
if email_account in email_string:
# ???
else:
print("This email doesn't exist in our records.")
main()
email_account in email_stringdoesn't work, because("Luke", "TonyHawk123!", "[email protected]")is what's inemail_string. You would need to extract the email address and probably put it into a dictionary for retrieval.