There is a situation where i have to find the element in a list whose corresponding value in a dictionary is minimum.
So here "boxes" is a list and "values" is a dictionary.
I have tried the following and this seems to work,
minvalue = 10
for box in boxes:
    if len(values[box]) > 1:
        if len(values[box]) < minvalue:
            minvalue = len(values[box])
            bestbox = box
But this is another way of doing the same thing but i don't get this line of code
n, s = min((len(values[s]), s) for s in boxes if len(values[s]) > 1)
 
    