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

Method __str__

matrix/matrix_class.py:232–246  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

230 return str(self.rows)
231
232 def __str__(self) -> str:
233 if self.num_rows == 0:
234 return "[]"
235 if self.num_rows == 1:
236 return "[[" + ". ".join(str(self.rows[0])) + "]]"
237 return (
238 "["
239 + "\n ".join(
240 [
241 "[" + ". ".join([str(value) for value in row]) + ".]"
242 for row in self.rows
243 ]
244 )
245 + "]"
246 )
247
248 # MATRIX MANIPULATION
249 def add_row(self, row: list[int], position: int | None = None) -> None:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected