Question: Suppose I have a list of tuples like:

```
listTuples = [(0, 3), (5, 10), (2, 4)] 

```

I want to get the index of the tuple with the largest difference between the tuple elements

```
3 - 0 = 3
10 - 5 = 5
4 - 2 = 2

```

So I want 1 as return.

Currently I am doing the following but perhaps there is a better way (faster, fewer lines of code) to do it.

```
listTuples = [(0, 3), (5, 10), (2, 4)] 

k = 0
e = 0

for j, i in enumerate(listTuples):
    diff = i[1] - i[0]
    if k < diff:
        k = diff
        e = j
    else:
        pass

print(e)

```

Answer: 
Use `max()` with a custom key:

```
max(enumerate(listTuples), key = lambda x: x[1][1]-x[1][0])[0]

```
you can use the builtin `max` with a custom key function, like this:

```py
max(range(len(listTuples)), key=lambda i: listTuples[i][1] - listTuples[i][0])

```

It gives a value from `range(len(listTuples))`, based on the maximum value returned for each element from the `key` function.