Start from this simple skeleton:
class Matrix:
def __init__(self, matrix):
self.matrix = matrix
def double_diagnonal_entries(self):
# do calcs
return self.matrix
Note, that if you need to implement some basic matrix ops like addition you might consider operator overloading such as:
def __add__(self, another_matrix):
# do the math
return sum_matrix
solved Create a class that takes a matrix for instantiation