Archived
1
0
Fork 0
This repository has been archived on 2024-05-10. You can view files and clone it, but cannot push or open issues or pull requests.
PY4E/Assignment 10.2/main.py

17 lines
407 B
Python
Raw Normal View History

2021-09-08 10:33:48 -05:00
name = input("Enter file:")
if len(name) < 1:
name = "mbox-short.txt"
handle = open(name)
emailhour = dict()
for line in handle:
line = line.strip().split()
if len(line) > 0:
if line[0] == "From":
hour = line[5].split(":")[0]
emailhour[hour] = emailhour.get(hour, 0) + 1
for hour,numberofemails in sorted(emailhour.items()):
print(hour,numberofemails)