Advertisement
AlexG2230954

ДЗ. Задание 3

May 21st, 2022
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. from collections import Counter
  2.  
  3. votes = []
  4. total_votes = 0
  5.  
  6. while True:
  7.     try: vote = input()
  8.     except EOFError: break
  9.  
  10.     votes.append(vote)
  11.     total_votes += 1
  12.  
  13.  
  14. votes_count = Counter(votes)
  15. winners = votes_count.most_common(2)
  16.  
  17. print(winners[0][0])
  18.  
  19. if winners[0][1] / total_votes <= 0.5:
  20.     print(winners[1][0])
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement