I have a nested list of integers and tuples:
orders = [[1, ('5464', 49.96), ('8274', 233.82), ('9744', 404.55)]
[2, ('5464', 99.91), ('9744', 404.55)]
[3, ('5464', 99.91), ('88112', 274.89)]
[4, ('8732', 93.93), ('7733', 208.89), ('88112', 199.75)]]
I want to get the minimum(output):
[(1, '5464')
(2, '5464')
(3, '5464')
(4, '8732')]
How do I get the output using only list comprehension(no loops and other functions)?
My try:
p = [[x if type(x) != tuple else min(y[1:])[1] for x in y] for y in orders]
print(p)
output:
[[1, 49.96, 49.96, 49.96], [2, 99.91, 99.91], [3, 99.91, 99.91], [4, 208.89, 208.89, 208.89]]