Suppose, I have 3 Python lists
l1 = [2, 5, 2, 4, 1]
l2 = [5, 1, 6, 3, 9]
l3 = [4, 9, 1, 8, 4]
I want to get list name for which the corresponding index would have the lowest values.
Like for 0th index
l1 = 2
, l2 = 4
and l3 = 4
In this case, after applying the min
function I would get 2 as the answer. I want that instead of getting the value I want the list name from which it was selected(i.e l1
for this example)
I did try using min inside the for loop but that just gives minimum from the three lists and cannot get the list name
l1 = [2, 5, 2, 4, 1]
l2 = [5, 1, 6, 3, 9]
l3 = [4, 9, 1, 8, 4]
for i in range(len(l1)):
print(min(l1[i], l2[i], l3[i]))
The output I got:
2 1 1 3 1
So, for the above example, the expected output would be l = [l1, l2, l3, l2, l1]