Click here to Skip to main content
15,742,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
 matrix = [[2.7, 3.4, 5.2, 6.8],
            [3.6, 5.2, 6.8, 7.5],
            [6.7, 7.5, 8.4, 8.9]]

row = int(input("Enter row :"))
column = int(input("Enter column :"))

lets say if user select 3.6 (matrix[0][1]), then how to print 5.2(matrix[1][1])?

What I have tried:

I have tried
print(matrix[row][column + 1])
but it doesn't work for all selection.
[no name] 24-Apr-21 13:20pm    
Loop over all rows/columns of the matrix, compare the value with the given choice and print if it is appropriate. In your case: Appropriate= matrix[row][col] >= value ;)
Uups, sorry: Looks like 'next column' is important. In this case it becomes something more complicated in the sense you will not scan the whole matrix but only certain columns and you need first to determine the starting column
Richard MacCutchan 25-Apr-21 3:49am    
You first need to check the values of row and column to ensure they are within the range of rows and columns. Also check that column + 1 is not out of range.

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