I'm writing a program which will need a user to register and login with an account. I get the program to have the user make their username and password which are saved in an external text file (accountfile.txt), but when it comes to the login I have no idea how to get the program to check if what the user inputs is present in the text file.
This is what my bit of code looks like :
def main():
register()
def register():
username = input("Please input the first 2 letters of your first name and your birth year ")
password = input("Please input your desired password ")
file = open("accountfile.txt","a")
file.write(username)
file.write(" ")
file.write(password)
file.close()
login()
def login():
check = open("accountfile.txt","r")
username = input("Please enter your username")
password = input("Please enter your password")
I have no idea what to do from this point.
Also, this is what a registered account would look like in the text file:
Ha2001 examplepassword