MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / add_row

Method add_row

matrix/matrix_class.py:249–263  ·  view source on GitHub ↗
(self, row: list[int], position: int | None = None)

Source from the content-addressed store, hash-verified

247
248 # MATRIX MANIPULATION
249 def add_row(self, row: list[int], position: int | None = None) -> None:
250 type_error = TypeError("Row must be a list containing all ints and/or floats")
251 if not isinstance(row, list):
252 raise type_error
253 for value in row:
254 if not isinstance(value, (int, float)):
255 raise type_error
256 if len(row) != self.num_columns:
257 raise ValueError(
258 "Row must be equal in length to the other rows in the matrix"
259 )
260 if position is None:
261 self.rows.append(row)
262 else:
263 self.rows = [*self.rows[0:position], row, *self.rows[position:]]
264
265 def add_column(self, column: list[int], position: int | None = None) -> None:
266 type_error = TypeError(

Callers 1

display_billionairesFunction · 0.80

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected