Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pathlib import Path
- from collections import defaultdict
- mapping = defaultdict(int)
- with Path("chatmgs212.txt").open("rb") as file:
- for line in file:
- mapping[line.strip()] += 1
- with Path("how_manymgs21.txt").open("wb") as file:
- vals = sorted([(v,k) for k,v in mapping.items()],reverse=True)
- file.writelines([f"{n} - {v}: {k.decode()}\n".encode() for n,(v,k) in enumerate(vals,start=1)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement