FrankieD FrankieD - 10 months ago 97
Python Question

Python simple login

I have assignment in my school to create function with simple login from some file (users.txt) I'm not very good at Python 3.5 so I need help.

Data in users.txt looks like this:


separated by "|"

My job is to create simple login when program starts and continue to main_menu() if username and password input matches with one in users.txt file.

Thx :)

ps. I'm not supposed to use any advanced methods for login :(

Answer Source
def main_menu():
    print('successfull login!')

if __name__ == '__main__':
    user_name = input('Enter user name:')
    password = input('Enter password:')

    f = open('users.txt')
    file_content =
    users = file_content.split('\n')
    for user in users:
        user_array = user.split('|')
        current_username = user_array[2]
        current_password = user_array[3]
        if (current_username == user_name and current_password == password):