Changing the output a bit

前端 未结 1 614
-上瘾入骨i
-上瘾入骨i 2020-12-22 08:58

Question is:

voting_borda:

(list of list of str) -> tuple of (str, list of int)

The parameter is a list of 4-element lists that rep

相关标签:
1条回答
  • 2020-12-22 09:30

    The index thing (NDP_INDEX etc.) is really unnecessary and un-pythonic. Just use the string, and if you need to sort it according to something, use lists of tuples.

     vv = [ ('republican',3), ('democrat',9), ('libertarian',73), ('green',-2) ]
     vsort = sorted(vv,key=lambda x:x[1],reverse=True)
     print(list(party for party, value in vsort))
    

    You can do something similar to get your answer. Hate to do the entire assignment for you...

    0 讨论(0)
提交回复
热议问题