[Solved] How to call the minimum value in list 1 and respective value in list 2 in PYTHON [closed]


You can do it with min and zip quite easy:

l1 = [1,2,3,4,5,6]
l2 = [10,20,5,8,30,25]

l3 = zip(l2,l1)

print(min(l3))

Output:

(5, 3)

Comment

As mention in the comment by @sshashank124 it is important that the first list is the list you want to find the minimum. In this case it would be l2 that is why in zip(l2,l1) l2 is first and not l1. Otherwise it wouldn’t work and give you not the expected output.

As an example: min(zip(l1,l2)) would return (1, 10).

Edit

You get a tuple back. Depending on which of this 2 elements you want you can print it like this:

min_value = min(l3)

print(min_value[0],min_value[1])

Output:

5 3

3

solved How to call the minimum value in list 1 and respective value in list 2 in PYTHON [closed]