l = [[98, 25, 33,  9, 41],
[67, 32, 67, 27, 85],
[38, 79, 52, 40, 58],
[84, 76, 44,  9,  2]]

def fnd(l,value):
    for i,v in enumerate(l):
        if value in v:
            return {'row':i+1,'col':v.index(value)+1}
    return {'row':-1,'col':-1}
print(fnd(l,40))
{'row': 3, 'col': 4}
Answer from Kuldeep Singh Sidhu on Stack Overflow
🌐
Snakify
snakify.org › two-dimensional lists (arrays)
Two-dimensional lists (arrays) - Learn Python 3 - Snakify
You can use nested generators to create two-dimensional arrays, placing the generator of the list which is a string, inside the generator of all the strings. Recall that you can create a list of n rows and m columns using the generator (which ...
🌐
DEV Community
dev.to › drvcodenta › accessing-rows-and-columns-in-a-2d-array-and-insert-methodpython-2plo
accessing rows and columns in a 2d array and insert method(python) - DEV Community
March 17, 2024 - Accessing a row: To access a row in a 2D array, you only need one index. For example, matrix[i] will give you the ith row. Accessing a column: Accessing a column is a bit trickier because Python's list of lists structure does not have built-in ...
🌐
Scaler
scaler.com › home › topics › 2d array in python
2D Array in Python | Python Two-Dimensional Array - Scaler Topics
May 25, 2026 - Here r1c1 means that it is the ... We can directly access values or elements of a 2D array in Python. It can be done by using the row and column indices of the element to be accessed....
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-using-2d-arrays-lists-the-right-way
Using 2D arrays/lists in Python - GeeksforGeeks
Manually initializing and populating ... a list of size N. ... Explanation: range(N) controls list length. A 2D list represents data in rows and columns....
Published: December 20, 2025
🌐
Medium
theizharahmad.medium.com › 2d-arrays-in-python-08ff7c287b2a
2D Arrays in Python. 2D arrays, also known as a matrix, are… | by Izhar Ahmad | Medium
September 7, 2024 - The nested lists represent the rows and the elements of the nested lists are the columns. To access an element of a 2D array, we first index the table array to get a specific row and then we index that row to get a specific element.
🌐
Guru99
guru99.com › home › python › python 2d arrays: two-dimensional list examples
Python 2D Arrays: Two-Dimensional List Examples
July 10, 2026 - Python 2D Array is an array placed inside another array, forming rows and columns like a table.
Find elsewhere
🌐
Google
sites.google.com › rgc.aberdeen.sch.uk › rgcahcomputingrevision › software-design › data-types-and-structures › 2d-arrays
Advanced Higher Computing Revision - 2D Arrays
Python treats this as a list within a list. You will notice that we have initialised each element in the array with a value of 0. This would create a 2D array called my2dArray with 3 rows and 8 columns.
🌐
Online Lesson
articulate.strayer.edu › home › learning › python 2d array
Python 2D Array - Online Lesson
January 22, 2026 - A Python 2D array is essentially a list of lists. Each inner list represents a row in the matrix, and the elements within these lists represent the columns.
🌐
Drbeane
drbeane.github.io › python_dsci › pages › array_2d.html
2-Dimensional Arrays — Python for Data Science
To access elements within a 2D array, we use the familiar square brace notation for indexing. Within the braces, we need to supply two numbers separated by a comma. The first number indexes a row in the array and the second number indexes a column.
🌐
Python Guides
pythonguides.com › python-numpy-2d-array
2D Array in Python: Nested Lists and NumPy Examples
May 9, 2025 - A 2D array in Python is a table of values arranged in rows and columns. Python has no built-in 2D array type, so you use either a nested list (a list of rows, like [[1, 2], [3, 4]]) or a NumPy 2D array created with np.array(), np.zeros() and ...
🌐
AskPython
askpython.com › python › two-dimensional-array-in-python
Two Dimensional Array in Python - AskPython
December 27, 2019 - Input to a 2-D array is provided in the form of rows and columns. ... size = int(input()) array_input = [] for x in range(size): array_input.append([int(y) for y in input().split()]) print(array_input) ...
🌐
C# Corner
c-sharpcorner.com › home › technologies › python › how to represent a matrix using 2d arrays using python
How to Represent a Matrix Using 2D Arrays using Python
October 6, 2025 - from typing import List, Any import unittest def create_2d_array(rows: int, cols: int, fill_value: Any = 0) -> List[List[Any]]: """ Safely create a 2D array (matrix) with independent rows. Args: rows: Number of rows cols: Number of columns fill_value: Value to fill the matrix with (default: 0) Returns: A rows x cols 2D list with deep-independent rows Raises: ValueError: If rows or cols are negative """ if rows < 0 or cols < 0: raise ValueError("Rows and columns must be non-negative.") return [[fill_value for _ in range(cols)] for _ in range(rows)] def update_traffic_matrix(matrix: List[List[in
🌐
Cf
physics-python.astro.cf.ac.uk › Week6
PX1224 -Week6: Two Dimensional Arrays
r0 = d2[0,:] #Extract the first Row and call it r0 c0 = d2[:,0] #Extract the first Column and call it c0 c3 = d2[:,3] #Extract the 4th Column and call it c4 · It is often useful to extract 1-dimensional slices of 2-d arrays for further investigation. 2-d Arrays can be multiplied just as 1-d arrays can be; all mathematical operations that work with single variables (i.e. single numbers) (addition, subtraction, division, raising to a power, sin etc.) work with 2D arrays element-by-element. It is possible to find the maximum entry in a 2-d array, however, if you try using python's max() function, you will get an error
🌐
Finxter
blog.finxter.com › home › learn python blog › how to create a two dimensional array in python?
How To Create a Two Dimensional Array in Python? - Be on the Right Side of Change
June 11, 2022 - Syntax: array_2d[row_number][column_number]= element · Example: To assign values to all the elements of the first row, use the following syntax: ... Another way of creating 2D arrays in Python without using an external module is to use Python dictionaries.
🌐
w3resource
w3resource.com › python-exercises › python-conditional-exercise-11.php
Python Exercise: Generates a two-dimensional array - w3resource
The element value in the i-th row and j-th column of the array should be i*j. Note : i = 0,1.., m-1 j = 0,1, n-1. ... # Prompt the user to input the number of rows row_num = int(input("Input number of rows: ")) # Prompt the user to input the ...