Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inFile = open('input.txt', 'r', encoding='utf8')
- outFile = open('output.txt', 'w', encoding='utf8')
- string = inFile.readlines()
- c = {}
- countVoices = 0
- for d in string:
- p = d.strip()
- c[p] = c.get(p, 0) + 1
- countVoices += 1
- c = sorted(c.items(), key=lambda x: x[1], reverse=True)
- percent = c[0][1] / countVoices * 100
- if percent > 50:
- print(c[0][0], file=outFile)
- else:
- for name, _ in c[:2]:
- print(name, file=outFile)
- inFile.close()
- outFile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement