jeudi 17 octobre 2019

How do you write an anonymous function to find the max value of two parameters passed to the function using if and else statements?

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

I'm trying to write an anonymous function that with find the max value of two parameters passed to it from a single list using if and else logic. Then use the anonymous function to find the maximum value in myList. I have no idea how to incorporate if and else.

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

maxMyList = map(lambda x: x + x, myList)
print(list(maxMyList))

Just doubles the current list numbers

Aucun commentaire:

Enregistrer un commentaire