I am building a cypher program which uses a matrix of numbers and letters. A message is encoded according to the row and column each letter of the message is found in the matrix.
I am trying to find a nice way of iterating over the 2D matrix (6*6).
for char in range (0, len(message), 1):
for i in range(0, len(rows), 1):
for y in range(0, len(cols), 1):
if matrix[i][y] == message[char]:
cyphermessage.append(i)
cyphermessage.append(y)
cyphermessage.append(" ")
But this method uses a 3-tier for
loop which makes it \$\mathcal{O}((N)*3)\$, plus the the cypher append messages are quite ugly.