Click here to Skip to main content
15,566,394 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to find a way to associate an unknown value with the data it's supposed to be associated with it. Example: account number with the relevant information and then extract the specific value I need to use from the list of information available for this specific account.

What I have tried:

matrix_accounts = [["1", "Kamal Mohsen", 13000],
                   ["2", "Sherif Lasheen", 340],
                   ["3", "Karma Mourad", 60000],
                   ["4", "Nermeen Hossam", 20],
                   ["5", "Fady Gamal", 9000]]

account_number_required = int(input("Hello, please insert account number"))

matrix_length = len(matrix_accounts)

for i in range(matrix_length):
    if account_number_required == matrix_accounts[i][0]:
print("Hello", matrix_accounts[i])

What I would like to get, is for the code to loop through the matrix's first row to check if the input exists in the matrix. And then to recognise the row in which the value it has found is situated and then print the whole row or a specific value that I need from that row.
Updated 4-Jan-21 18:29pm

1 solution

Your column offset is incorrect. The account numbers are in offset 2.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900