Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- from itertools import groupby
- with open("massa.txt") as fobj:
- lasts = (line.rsplit(".", 1)[-1].strip() for line in fobj.readlines())
- groups = groupby(sorted(lasts))
- items = ((sum(1 for el in group), ext) for ext, group in groups)
- for item in sorted(items, reverse=True):
- print("%3d %s" % item)
- # Based on https://www.facebook.com/pythonbrasil/photos/a.582882565067606.1073741825.328258703863328/776054062417121/
Advertisement
Add Comment
Please, Sign In to add comment