Question: I was given a task which was to find the largest value in a list using a lambda function. With the lambda function, I must have two parameters and I am having a hard time how to retrieve elements from a list to use in a lambda function.

I understand how to perform the task by defining a function but I do not know how to translate that to a lambda function.

```
myList = [1,2,3,4,5,6,7,8,9,10]

#Here I can find the max value by defining a function

def maxVal(list_a):

   max = 0

   for i in list_a:

       if i > max:
          max = i
   return max
print(maxVal(myList))

#Here I attempt to use a lambda function to find the max value

maxMyList = map(lambda x,y: x[0] >= y[0], myList, myList)

print(maxMyList(myList,myList))

```

Edit: Sorry for any confusion as this is my first time posting here. Just for clarity, I CANNOT define any functions for use in this program. I just wanted to post the code for the defined function maxVal to show that I understand the logic of what I need to do. Thank you for all of your responses, I really appreciate it!

Answer: 
There is really nothing wrong with the way you were going about this. You just needed to incorporate your lambda into the rest of your code in the right way:

```
myList = [1,2,3,10,4,5,6,7,8,9]

def maxVal(list_a, compare_function):
    max = -sys.maxsize - 1  # strange but true...this seems to be the canonical way to get the smallest 32 bit `int`
    for i in list_a:
        if compare_function(i, max):
            max = i
    return max

my_compare_function = lambda x,y: max(x, y)

print(maxVal(myList, my_compare_function))

```

Result:

```
10

```

I did have to change at what level `return max` was being called. I don't know if this was a logic error, or just a transcription error when you put your code into a S.O. question. Also note that I moved the 10 to a different place in your input data to make sure it didn't have to be at the end to be found to be the largest value.

If you want a "cooler" and more modern answer, `reduce` is really designed to do just what you want. Here's a simple solution.

```
import functools

myList = [1,2,3,10,4,5,6,7,8,9]
r =  functools.reduce(lambda v1, v2: max(v1, v2), myList)
print(r)

```

Result:

```
10

```

Also note that 'max' itself is a function that takes two parameters, so you could use it directly to get to something very simple...not that this works in your case where your assignment is to use a lambda:

```
myList = [1,2,3,10,4,5,6,7,8,9]
r =  functools.reduce(max, myList)
print(r)

```

These functional equivalents to writing loops are all the rage, and for good reason. When combined with processing data as streams, it's a super powerful idea. And as it becomes more popular, I think it will be thought to be more readable. As an old timer, I'm just getting on board with all of this functional/streams programming...more in Java than Python, but still. It's a powerful set of tools that would be to your benefit to really understand well.
You can define a function that takes a list as the first parameter and optionally a current maximum as the second parameter, and recursively calls itself with the first item in the list as the second argument if it's bigger than the current maximum or if the current maximum is `None`, and the rest of the list as the first argument, until the rest of the list is empty, at which point returns the current maximum:

```
maxVal = lambda lst, m=None: maxVal(lst[1:], m if m is not None and lst[0] < m else lst[0]) if lst else m

```

so that:

```
from random import shuffle
myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
shuffle(myList)
print(maxVal(myList))

```

outputs: `10`