def make_cost_matrix(profit_matrix, inversion_function):
 cost_matrix = []
 for row in profit_matrix:
  cost_matrix.append([inversion_function(value) for value in row])
 return cost_matrix

def make_cost_matrix ( profit_matrix , inversion_function ) : cost_matrix = [ ] for row in profit_matrix : cost_matrix . append ( [ inversion_function ( value ) for value in row ] ) return cost_matrix
create a cost matrix from a profit matrix by calling inversion_function to invert each value .