Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- city1 = 'foo'
- city2 = 'bar'
- lines = [
- ['fasf', 2],
- ['foo', 1],
- ['saf', 3],
- ['asf', 5],
- ['bar', 15],
- ['fgyj', 6],
- ['bar', 12]
- ]
- city1 = sorted([line for line in lines if line[0] == city1], key=lambda x: x[1])
- city2 = sorted([line for line in lines if line[0] == city2], key=lambda x: x[1])
- city1 = city1[-1] if city1 else None
- city2 = city2[-1] if city2 else None
- print(city1)
- print(city2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement