开发者

may i know how can we compare lists [closed]

开发者 https://www.devze.com 2023-01-29 00:16 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

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 is if i want to know which players has good han开发者_StackOverflow社区d mean good list for example by comapring list to list, if rate1==rate2(list2 in the list of lists) then i have to check is their rank are also same if that condition also true then i have to go to next value in the same list and check with the other list having same first two values. if both lists are equal then we say they are equal else we find the greater one(rate,rank or max)

and this is for infinite list where i dont know what is the length of the list and its charcters

i hope you understand it know


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


Perhaps you mean something like this

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

精彩评论

暂无评论...
验证码 换一张
取 消