AlexG2230954

ЕГЭ № 5. Задание 3

May 28th, 2022 (edited)
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. from collections import Counter
  2.  
  3.  
  4. with open("input.txt", "r", encoding="utf-8") as file:
  5. buys_count = Counter()
  6. buys = [line.strip() for line in file.readlines()]
  7.  
  8. for buy in buys:
  9. buys_count.update(buy.split(","))
  10.  
  11. max_count = buys_count.most_common(1)[0][1]
  12. max_buy = ""
  13.  
  14. for buy in buys_count.most_common():
  15. if buy[1] == max_count:
  16. if buy[0] <= max_buy or max_buy == "":
  17. max_buy = buy[0]
  18.  
  19. print(max_buy)
Add Comment
Please, Sign In to add comment