when dealing with 2D arrays do we need to use a for loop to search an item in the list /u/Antique_Shallot_3403 Python Education

`for example

user_database = [ [“Ojku”, “password123”], [“Cbugo”, “Pass”], [“Amara”, “securepassword”] ]

def authenticate_user(username, password): for user in user_database: if user[0] == username: if user[1] == password: return “Access granted. Welcome!” else: return “Password incorrect. Access denied.” return “Username not found. Access denied.” `

submitted by /u/Antique_Shallot_3403
[link] [comments]

​r/learnpython `for example user_database = [ [“Ojku”, “password123”], [“Cbugo”, “Pass”], [“Amara”, “securepassword”] ] def authenticate_user(username, password): for user in user_database: if user[0] == username: if user[1] == password: return “Access granted. Welcome!” else: return “Password incorrect. Access denied.” return “Username not found. Access denied.” ` submitted by /u/Antique_Shallot_3403 [link] [comments] 

`for example

user_database = [ [“Ojku”, “password123”], [“Cbugo”, “Pass”], [“Amara”, “securepassword”] ]

def authenticate_user(username, password): for user in user_database: if user[0] == username: if user[1] == password: return “Access granted. Welcome!” else: return “Password incorrect. Access denied.” return “Username not found. Access denied.” `

submitted by /u/Antique_Shallot_3403
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *