Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import Counter
- with open("input.txt", "r", encoding="utf-8") as file:
- buys_count = Counter()
- buys = [line.strip() for line in file.readlines()]
- for buy in buys:
- buys_count.update(buy.split(","))
- max_count = buys_count.most_common(1)[0][1]
- max_buy = ""
- for buy in buys_count.most_common():
- if buy[1] == max_count:
- if buy[0] <= max_buy or max_buy == "":
- max_buy = buy[0]
- print(max_buy)
Add Comment
Please, Sign In to add comment