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 = f.read()
users = {}
status = “”
def displayMenu():
status = input("Do You have an account? y/n? Press q to quit: ")
if status == “y”:
oldUser()
elif status == “n”:
newUser()
def newUser():
createLogin = input("Please Enter your student ID: ")
if createLogin in users:
print("\nLogin name already exist!\n")
else:
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")
else:
print("\nUser doesn't exist or wrong password!\n")
while status != “q”:
displayMenu()