Question: Hi, Really need help with a python assignment, how do i do the below functions. can post extra info if needed, the files that are
Hi,
Really need help with a python assignment, how do i do the below functions. can post extra info if needed, the files that are referred to are just text files formatted as "Username - Password" without the parenthesis, also there are some blank spaces. if you need raw code posted let me know, or more info


H 2]: #*# TEST YOUR SOLUTION ### user_accounts, log_in = import_and_create_accounts ("user.txt") tools.assert_false(len(user_accounts) 0) tools.assert_false(len(log_in) == ) tools.assert equal (user_accounts.get("Brandon"), "brandon123ABC") tools.assert_equal(user_accounts. s.get("Jack")," jack123POU") tools.assert_is_none (user_accounts.get("Jennie")) tools.assert_false (log_in["Sarah"]) In [41]: def import_and_create_accounts(filename): This function is used to create an user accounts dictionary and another login dictionary. The given argument is the filename Every line in the file will look like username - password If the username and password fulfills the requirement, add the username and password into the user accounts dictionary. To make sure that the password fulfills these requirements, be sure to use the signup function that you wrote above. For the login dictionary, the key is the username, and its value indicates whether the user is logged in, or not. Initially, all users are not logged in. Finally, return the dictionaries. Note: All of the users in the bank file are in the user account file. user_accounts = {} log_in = {} # your code here def signup(user_accounts, log_in, username, password): This function allows users to sign up. If both username and password meet the requirements, updates the username and the corresponding password in the user_accounts and returns True. If the username and password fail to meet any one of the following requirements, returns False. - The username already exists in the user_accounts. The password must be at least 8 characters. The password must contain at least one lowercase character. The password must contain at least one uppercase character. The password must contain at least one number. The username & password cannot be the same. For example: - Calling signup (user_accounts, log_in, "Brandon", "123abcABCD") will return false - Calling signup(user_accounts, log_in, "Brandonk", "123ABCD") will return false - Calling signup (user_accounts, log_in, "Brandonk", "abcdABCD") will return false - Calling signup (user_accounts, log_in, "Brandonk", "123aABCD") will return True. Then calling signup(user_accounts, log_in, "Brandonk", "123aABCD") again will return false. Hint: Think about defining and using a separate valid(password) function that checks the validity of a given password. This will also come in handy when writing the change_password() function. # your code here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
