Given a specific string, my function needs to create a list of lists using all of the characters from that string. The function should start a new list whenever it sees \n in the string.
Example: build_lst("\n....\n.B.d\n") should return this list of lists: [['.','.','.','.'],['.','B','.','d']] because those 8 characters were present in the string. It creates the list of lists in the order that the characters appear in the string and as I mentioned \n divides the multiple individual lists within the main list.
My code so far is short but I think this could be accomplished with just a couple lines of code. Not sure if I am on the right track or if another strategy is better
Code:
def build_lst(s):
my_lst = s.split('\n')
[map(int) for x in my_lst]
[list(x) for x in "\n....\n.B.d\n".strip().split("\n")].map(int)? how does that relate to your expected output?