Python 3 Write Function Named Passwordcheck Authenticate User S Login Accepting User S Nam Q37271449

In python 3,

Write a function named passwordCheck() that will authenticate auser’s login by accepting that user’s name, their password, and adictionary of users’ login credentials. The function will returnthe str “login successful” if the user’s login information iscorrect and the str “login failed” otherwise.

Example1:

username: ‘user2’

password: ‘P@ssword2’

users = {‘user1′:’password1’, ‘user2′:’P@ssword2′,’user3′:’p#ssword33’, ‘user4′:’P&ssw0rd4’}

Returned: login successful

Example2:

username: ‘user3’

password: ‘P#ssword33’

users = {‘user1′:’password1’, ‘user2′:’P@ssword2′,’user3′:’p#ssword33’, ‘user4′:’P&ssw0rd4’}

Returned: login failed


Answer


def passwordCheck(username, password, users): if(not username in users.keys()): return False elif(users[username] == password): return True else:

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.