im new to python and im trying to create a login system in python 3.7.3. There are two separate files called Usernames and Passwords. When i run the code it ruturns usernames not defined.
def Files(): with open("Passwords.txt", "r") as f: passwords = [line.rstrip('\n') for line in f] f.close with open("Usernames.txt", "r") as f: usernames = [line.rstrip('\n') for line in f] f.close return passwords, usernames def login(usernames, passwords): global enter_username enter_username = input("Input your username") if enter_username in usernames: enter_password = input("Input your password") if enter_password in passwords: username_pos = usernames.index(enter_username) password_pos = passwords.index(enter_password) if username_pos == password_pos: print("well done you logged in", enter_username) return True else: print("your password does not match the username") else: print("password not found") else: print("username is not authorised") return False login(usernames, passwords)