import numpy as np list_of_lists = np.random.randint(10, size=(4,4)) print(list_of_lists) np.diag(list_of_lists)