Skip to content

Instantly share code, notes, and snippets.

@beltiras
Forked from gunnarig/ipfehoe.py
Last active October 14, 2018 22:43
Show Gist options
  • Save beltiras/0e0359a9142b55341cce4e64f12ca2c2 to your computer and use it in GitHub Desktop.
Save beltiras/0e0359a9142b55341cce4e64f12ca2c2 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 = []
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