I am trying to write a function that goes through a matrix. When a criteria is met, it remembers the location.
I start with an empty list:
locations = []
As the function goes through the rows, I append the coordinates using:
locations.append(x)
locations.append(y)
At the end of the function the list looks like so:
locations = [xyxyxyxyxyxy]
My question is:
Using append, is it possible to make the list so it follows this format:
locations = [[[xy][xy][xy]][[xy][xy][xy]]]
where the first bracket symbolizes the locations of a row in the matrix and each location is in it's own bracket within the row?
In this example the first bracket is the first row with a total of 3 coordinates, then a second bracket symbolizing the 2nd row with another 3 coordinates.
Try this:
Try something like:
Test
Instead of
You can do
This will append a list containing x.
So to do what you want build up the list you want to add, then append that list (rather than just appending the values). Something like:
simple example
result: