Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. >>> l = [['NSW', '87'], ['QLD', '49'], ['SA', '14'], ['VIC', '54'], ['WA', '19']]
  2.  
  3. >>> highest = max(item[1] for item in l)
  4. >>> (print(item) for item in l if item[1] == highest)
  5. ['NSW', '87']
  6.  
  7. >>> highest = max(item[1] for item in l)
  8. >>> for item in l:
  9. ... if item[1] == highest:
  10. ... print(item)
  11. ['NSW', '87']
  12.  
  13. >>> keys, values = zip(*l)
  14. >>> highest = max(values)
  15. >>> print([keys[values.index(highest)], highest])
  16. ['NSW', '87']
  17.  
  18. 1.819037475 # First Example
  19. 1.648459721 # Second Example
  20. 1.406044623 # Third Example
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement