0
I’m trying to apply heuristics to a code that I’ve been working on, but I need to get the smallest element from a sub-list, from a list. example:
L = [[1, 1, 6], [1, 2, 5], [1, 3, 7],
[2, 1, 1], [2, 2, 9], [2, 3, 4],
[3, 1, 5], [3, 2, 2], [3, 3, 3]]
For each of the sub-lists L[ ][0] and L[ ][1] are coordinates x and y (The first two sub-list elements are x and y) and L[ ][2] (Third element) are the values I need to verify. How can I check all the sub-lists, and return the smaller L[ ][2]? That in this example is L[3][2].
It wasn’t very clear what you need to do. What they are
x
andy
? Why the result should beL[3][2]
? This value will be the last 1 in the sub-list[2, 1, 1]
. That’s right?– Woss
x e y are the first two values of each sublist, and the result I was looking for was the smallest third element, among all sublists. In that case, the result should be L[3][2], as of all sub-lists, the third element of the fourth sub-list, and the lowest value compared to the others.
– Marcos Vinícius