Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. city1 = 'foo'
  2. city2 = 'bar'
  3.  
  4. lines = [
  5. ['fasf', 2],
  6. ['foo', 1],
  7. ['saf', 3],
  8. ['asf', 5],
  9. ['bar', 15],
  10. ['fgyj', 6],
  11. ['bar', 12]
  12. ]
  13.  
  14. city1 = sorted([line for line in lines if line[0] == city1], key=lambda x: x[1])
  15. city2 = sorted([line for line in lines if line[0] == city2], key=lambda x: x[1])
  16.  
  17.  
  18. city1 = city1[-1] if city1 else None
  19. city2 = city2[-1] if city2 else None
  20.  
  21. print(city1)
  22. print(city2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement