Skip to content

Instantly share code, notes, and snippets.

@gunnarig
Created October 14, 2018 22:42
Show Gist options
  • Save gunnarig/fb0be1df51a5b8a82853149758fe81ab to your computer and use it in GitHub Desktop.
Save gunnarig/fb0be1df51a5b8a82853149758fe81ab to your computer and use it in GitHub Desktop.
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 = []
[list_of_lists[len(list_of_lists)-x-1][x] for x in range(len(list_of_lists))]
x.append(x)
[list_of_lists[x][x] for x in range(len(list_of_lists))]
diag.append(x)
list_of_lists.extend(diag)
print(list_of_lists)
make_diagonal(list_of_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment