Get max value from a list with lists?

前端 未结 7 535
南笙
南笙 2020-12-09 11:32

So I have a list that contains several list which all have three strings first, then one float number, like:

resultlist = [[\"1\", \"1\", \"a\", 8.3931], [\         


        
7条回答
  •  失恋的感觉
    2020-12-09 12:10

    In perhaps a more functional than pythonic manner:

    >>> max(map(lambda x: x[3], resultlist))
    9.1931
    

    It begins by mapping each element of result list to the number value and then finds the max.

    The intermediate array is:

    >>> map(lambda x: x[3], resultlist)
    [8.3931000000000004, 6.3231000000000002, 9.1930999999999994]
    

提交回复
热议问题