Python text file

Hello, I’m a beginner I want to create a login and register system using a text file I have don’t this bit I don’t know how can I add it with my text file to check if the user id and password are matching or not and for register I want it that everyone registered will be added as well.

with open(‘students.txt’) as f:
contents =
users = {}
status = “”

def displayMenu():
status = input("Do You have an account? y/n? Press q to quit: ")
if status == “y”:
elif status == “n”:

def newUser():
createLogin = input("Please Enter your student ID: ")

if createLogin in users:
    print("\nLogin name already exist!\n")
    createPassw = input("Create password: ")
    users[createLogin] = createPassw
    print("\nUser created\n")

def oldUser():
login = input("Enter Student ID: ")
passw = input("Enter password: ")

if login in users and users[login] == passw:
    print("\nLogin successful!\n")
    print("\nUser doesn't exist or wrong password!\n")

while status != “q”:

Using a flat-file solution for storing users credentials is a bad idea, even more so if the file is in plain text.
I strongly advise you against this approach for various reasons — including potential legal consequences for adopting an insecure system to store credential and personal data (online or otherwise).

You should also consider that without a firm knowledge on security issues related to input strings sanitation, you will be exposing yourself to all sorts of attacks.

There are many third party libraries to choose from in this field, just find the one that best meets your needs. The obvious advantages are that you’d be benefiting from library updates and patches, bug fixes, and being spared having to re-invent the wheel.