Skip to content Skip to sidebar Skip to footer

May I Know How Can We Compare Lists

ok i m making a game poker card evaluator and i am storing its values in list of list and each list is containing the values like the [rate,rank,max] or just [1,2,3] so my question

Solution 1:

Sequences are already compared element-wise; there is nothing you need to do in order to invoke the desired behavior.


Solution 2:

Perhaps you mean something like this

>>> from operator import itemgetter
>>> L = [[1,2],[1,2],[1,4]]
>>> max(L, key=itemgetter(1))
[1, 4]

Post a Comment for "May I Know How Can We Compare Lists"