Created
October 28, 2020 14:45
-
-
Save martisj/45d2977cb093eb36daff0b49e63def7f to your computer and use it in GitHub Desktop.
Matrixify your life
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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