Skip to content

Instantly share code, notes, and snippets.

@delululala
Created September 13, 2025 10:57
Show Gist options
  • Select an option

  • Save delululala/eef2752b97900fba3d185c4fc6eafbae to your computer and use it in GitHub Desktop.

Select an option

Save delululala/eef2752b97900fba3d185c4fc6eafbae to your computer and use it in GitHub Desktop.
Python4E Exercice
name = input("Enter file:")
if len(name) < 1:
name = "mbox-short.txt"
handle = open(name)
counts = dict()
for line in handle:
line = line.strip()
if line.startswith('From '):
word = line.split()
time = word[5]
hour = time.split(':')[0]
counts[hour] = counts.get(hour,0) + 1
for k,v in sorted(counts.items()):
print(k,v)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment