Skip to content

Instantly share code, notes, and snippets.

@martisj
Created October 28, 2020 14:45
Show Gist options
  • Save martisj/45d2977cb093eb36daff0b49e63def7f to your computer and use it in GitHub Desktop.
Save martisj/45d2977cb093eb36daff0b49e63def7f to your computer and use it in GitHub Desktop.
Matrixify your life
class Matrix:
def __init__(self, matrix_string):
self.matrix = matrix_string.split("\n")
def row(self, index):
row = self.matrix[index - 1]
row_list = row.split()
final_list = list(map(int, row_list))
return final_list
def column(self, index):
columns = []
for row in self.matrix:
columns.append(row.split()[index - 1])
final_list = list(map(int, columns))
return final_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment