Question: python def login(user_accounts, log_in, username, password): ''' This function allows users to log in with their username and password. The users_accounts stores the usernames and

python

def login(user_accounts, log_in, username, password): ''' This function allows users to log in with their username and password. The users_accounts stores the usernames and passwords.

If the username does not exist or the password is incorrect, return False. Otherwise, return True.

For example: - Calling login(user_accounts, "Brandon", "123abcAB") will return False - Calling login(user_accounts, "Brandon", "brandon123ABC") will return True Note: If a user is already logged in, this should return False - a user cannot log in a second time once logged in '''

# your code here

########################## ### TEST YOUR SOLUTION ### ########################## bank = import_and_create_dictionary("bank.txt") user_accounts, log_in = import_and_create_accounts("user.txt")

tools.assert_false(login(user_accounts, log_in,"Brandon","123abcAB")) tools.assert_true(login(user_accounts, log_in,"Brandon","brandon123ABC")) tools.assert_false(login(user_accounts, log_in,"BrandonK","123abcABC"))

#user.txt

Brandon - brandon123ABC Jack Jack - jac123 Jack - jack123POU Patrick - patrick5678 Brandon - brandon123ABCD James - 100jamesABD Sarah - sd896ssfJJH Jennie - sadsaca

#bank.txt

Brandon: 5 Patrick: 18.9 Brandon: xyz Jack:

Sarah: 825 Jack : 45 Brandon: 10 James: 3.25 James: 125.62 Sarah: 2.43

Brandon: 100.5

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!