def buscar_elemento(matriz, elemento):
    for i, fila in enumerate(matriz):
        for j, valor in enumerate(fila):
            if valor == elemento:
                return (i, j)
    return None

# Ejemplo de uso
matriz = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]
]
elemento_a_buscar = 2
posicion = buscar_elemento(matriz, elemento_a_buscar)

if posicion:
    print(f"Elemento {elemento_a_buscar} encontrado en la posición {posicion}.")
else:
    print(f"Elemento {elemento_a_buscar} no encontrado en la matriz.")

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: