Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with open("input.txt") as f:
- goods = dict()
- for line in f.readlines():
- for good in line.strip().split(","):
- if good in goods:
- goods[good] += 1
- else:
- goods[good] = 1
- print(sorted(goods.items(), key=lambda x: (-x[1], x[0]))[0][0])
Add Comment
Please, Sign In to add comment