jootiee

Untitled

Apr 25th, 2022 (edited)
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. with open("input.txt") as f:
  2.     goods = dict()
  3.     for line in f.readlines():
  4.         for good in line.strip().split(","):
  5.             if good in goods:
  6.                 goods[good] += 1
  7.             else:
  8.                 goods[good] = 1
  9.     print(sorted(goods.items(), key=lambda x: (-x[1], x[0]))[0][0])
  10.  
Add Comment
Please, Sign In to add comment