Created
July 21, 2020 08:35
-
-
Save Victoria-Hodder/cf9929613e9c0bd75df4071e310ceaac to your computer and use it in GitHub Desktop.
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_string = matrix_string | |
def row(self, index): | |
row = list(self.matrix_string.split("\n")) | |
return row[index] | |
""" | |
My logic is: | |
1. Take the string | |
2. Split at \n | |
3. Convert this into list(s) within a list | |
4. Access the required row with an index | |
What I have so far prints: 5 6 7 8 | |
This fails the tests because it is expecting the output: [5, 6, 7, 8] | |
""" | |
def column(self, index): | |
pass | |
matrix = Matrix("1 2 3 4\n5 6 7 8\n9 8 7 6") | |
print(matrix.row(1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found a very cool solution in the community section. Now I work to understand it!!