Skip to content
  • About
  • Courses
  • Publications
  • Professional Certificates
  • Books
  • Patents
Download CV
Python

Churn Email: Day of the Week

Python Project – Churn Emails – Find Which Day of the Week the Email was sent

Write a function find_email_sent_days which reads the file /datasets/project/mbox-short.txt and categorizes each mail message by which day of the week the email was sent.

To do this do the following:

  • Open the file and read it line by line
  • Look for lines that start with “From“
  • For those lines which start from “From“, then look for the third word and keep a running count of each of the days of the week. How do you find the day of the week, is an exercise for you.

Note: You have to store the results in a dictionary. Only store those day of the week that exists. For Example, if there is no line for Mon then it should not be in the dictionary elements.

  • At the end of the program return the contents of your dictionary (order does not matter)

Sample Lines from the file:

From stephen.marquard@uct.ac.za Sat Jan  5 10:14:16 2008
From stephen.marquard@uct.ac.za Sat Jan  5 15:14:16 2008
From stephen.marquard@uct.ac.za Sun Jan  6 09:14:16 2008

Output:

{'Sat': 2, 'Sun': 1}

PS – If your logic is correct then your function should return this dictionary {'Sat': 1, 'Fri': 20, 'Thu': 6}.

Code:

def find_email_sent_days():
    with open("/cxldata/datasets/project/mbox-short.txt") as f:
        days = [i.split(' ')[2] for i in f if i.startswith('From ')]
        print (days)
        dic = {}
        for day in days:
            dic[day] = days.count(day)        
        return dic

Post navigation

Previous Previous
Compute the Compound Interest.py
NextContinue
Churn Emails – Count Number of Messages
Latest

🎓 Why Original Work Matters in Your Final Year Project (And How It Can Shape Your Career)

In engineering colleges across the country, final year projects are often treated as just another academic task. But what many students fail to realize is…

Read More 🎓 Why Original Work Matters in Your Final Year Project (And How It Can Shape Your Career)Continue

Latest

🎓 How to Choose Your Final Year Project: A Practical Guide for BTech Students

Choosing the right final year project is one of the most important decisions of your engineering journey. It’s more than just a submission — it’s…

Read More 🎓 How to Choose Your Final Year Project: A Practical Guide for BTech StudentsContinue

Latest

🧠 MCP Server: Model Context Prototyping with Gemini + MySQL + FastAPI

GitHub: https://github.com/nishantmunjal2003/mcp-server-gemini 📌 Project Overview MCP Server is a lightweight, extendable API server that: ⚙️ Features 📁 Folder Structure bashCopyEditmcp-server/ │ ├── app.py # Main…

Read More 🧠 MCP Server: Model Context Prototyping with Gemini + MySQL + FastAPIContinue

Artificial Intelligence Psychology

Why You Can’t Stop Scrolling — And What AI Has to Do With It

Ever caught yourself reaching for your phone, telling yourself it’s “just for a minute”… and then suddenly it’s midnight?You didn’t mean to spend the last…

Read More Why You Can’t Stop Scrolling — And What AI Has to Do With ItContinue

Latest

Advance AI PPT

Read More Advance AI PPTContinue

Nishant Munjal

Coding Humanity’s Future </>

Facebook Twitter Linkedin YouTube Github Email

Tools

  • SIP Calculator
  • EMI Calculator
  • Creative QR Code Generator Tool
  • Write with AI
  • Image Converter
  • SamplePHP

Resources

  • Blog
  • Contact
  • Refund and Returns

Legal

  • Disclaimer
  • Privacy Policy
  • Terms and Conditions

© 2025 - All Rights Reserved

  • About
  • Courses
  • Publications
  • Professional Certificates
  • Books
  • Patents
Download CV
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.