I have following code
li = [[[1,2],[3,4]]]
min([*x[0] for x in li])
I expected to see
Output: 1
But what happened is
SyntaxError: iterable unpacking cannot be used in comprehension
What is the problem?
I have following code
li = [[[1,2],[3,4]]]
min([*x[0] for x in li])
I expected to see
Output: 1
But what happened is
SyntaxError: iterable unpacking cannot be used in comprehension
What is the problem?
Or Just point the first element:
li = [[[1,2],[3,4]]]
min([x[0] for x in li[0]])
Or iterate all the canonized lists:
min([x[0] for xs in li for x in xs])
Probably, you are looking for something like this:
li = [[[1,2],[3,4]]]
min(li[0], key=lambda x: x[0])
If you would like to receive a pair with the minimum first argument, just provide your own comparison function to min
as key
.