Can python interpret lists in text files?
<p>I am trying to make a password keeper and I have the usernames and passwords of the user accounts in a text file. However, since the script wants to know if the user input for loginUser and loginPass are in the file, that creates the opportunity for the user to log in with mismatched usernames and passwords. Can I create a list (or at least a pair of strings) and check if the input for the login variables are in a specific list?</p>

<p>Here's my code If you want to test it yourself:</p>

<pre><code>def title():
    # This is the title screen
    print('____This is a password keeper____')
    main()


def main():
    abc = open("userpassfile.txt", "r+")
    userpassfile = abc.read().strip().split()
    actCheck = input('Do you already have an account?')
    if(actCheck == 'Yes' or actCheck == 'yes'):
        loginUser = input('What is your username?')
        loginPass = input('What is yout password?')
        if(loginUser and loginPass in userpassfile):
            dirCheck = input('Account Settings? [y/n]')
            if(dirCheck == 'y' or dirCheck == 'Y'):
                print('This function is not working yet!')
            else:
                print('hihi')
        else:
            print('Incorrect password or username!')
    else:
        createAct = input('would you like to create one?')
        if (createAct == 'Yes' or createAct == 'yes'):
            createUser = input('What would you like your username to be?:')
            createPass = input('What would you like your password to be?:')
            abc.write(createUser + '\n')
            abc.write(createPass + '\n')
            open(createUser + '.txt', "w")

title()
</code></pre>

<p>If you have any questions about my code, please ask! Thanks!</p>