I have the current string:
output = "S.##......\n#.##..###.\n#.###.###.\n#.....###.\n###.#####S"
I want to convert it to the following list:
coordinates = [['S', '.', '#', '#', '.', '.', '.', '.', '.', '.'],
['#', '.', '#', '#', '.', '.', '#', '#', '#', '.'],
['#', '.', '#', '#', '#', '.', '#', '#', '#', '.'],
['#', '.', '.', '.', '.', '.', '#', '#', '#', '.'],
['#', '#', '#', '.', '#', '#', '#', '#', '#', 'S']]
Basically every time I get a "\n" character, I want the sequence before it to be split like above and put in a separate list item. I tried the following:
coordinates = []
temp = []
for item in output:
if item != "\n":
temp += item
else:
coordinates += temp
but it doesn't work, neither it works with
.append()