-
-
Save beltiras/0e0359a9142b55341cce4e64f12ca2c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list_of_list = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]] | |
def make_diagonal(list_of_lists): | |
diag = [] | |
diag.append([list_of_lists[len(list_of_lists)-x-1][x] for x in range(len(list_of_lists))]) | |
diag.append([list_of_lists[x][x] for x in range(len(list_of_lists))]) | |
print(diag) | |
return diag | |
make_diagonal(list_of_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment