Write a function called login that accepts 3 parameters: userName:str, password: str, and data: dictionary. The data parameter is a dictionary containing userName keys and associated passwords for values. Your function is the check if the username and password passed by parameter are a matching key:value pair in the data dictionary. in python If the username is not a valid key in data it should return the string "The user name was not found" If the password is not correct for a username that is found in the data dictionary it should return the string "The password was incorrect" If the username is associated with a correct password it should return the string "Login successful" You can create an empty dictionary with dictionary() [ ] ( ) { } This data structure stores a collection of objects in an unordered manner where each object must be unique dictionary set tuple list
Write a function called login that accepts 3 parameters: userName:str, password: str, and data: dictionary. The data parameter is a dictionary containing userName keys and associated passwords for values. Your function is the check if the username and password passed by parameter are a matching key:value pair in the data dictionary.
in python
If the username is not a valid key in data it should return the string "The user name was not found"
If the password is not correct for a username that is found in the data dictionary it should return the string "The password was incorrect"
If the username is associated with a correct password it should return the string "Login successful"
-
You can create an empty dictionary with
dictionary()
[ ]
( )
{ }
-
This data structure stores a collection of objects in an unordered manner where each object must be unique
dictionary
set
tuple
list
-
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images