I have a matrix like the following:
matrix = [
["a", "b", "c", "d"],
["e", "f", "g", "h"],
["i", "j", "k", "l"],
["m", "n", "o", "p"]
]
And i'm trying to find the diagonals, but when I say diagonals I mean that I want all of the letters that are "diagonal" to eachother. Example, the ideal output would be:
["a", "eb", "ifc", "mjgd", "nkh", "ol","p"]
(I consider that a unique letter is diagonal to itself, and in this example it shows that I start from "a" which is the matrix[0][0] element, then from the second row to the second element etc...)
I have few ideas on how to approach this problem but I thought something like this
for row in matrix:
for i in range(len(row)):
for j in range(i, len(row)):
my_list.append(matrix[?][?])
I know it's not a lot but I can't manage how to declare the pattern that I want as index of list Thank you for your help.