Click on identity.py to get source.
def identity(n): return [[1 if i == j else 0 for i in range(n)] for j in range(n)] print(identity(3)) print([(i, j) for i in range(3) for j in range(3)])