SD 212 Spring 2025 / Homeworks


hw11: Midshipman email addresses

  • Due before the beginning of class on Monday, February 3

Your task

Write a Python program emails.py which inputs a filename and then searches for and prints out the email addresses of all current USNA Midshipmen in the file. Current means classes 2025-28.

You will want to use the re module for regular expressions, and the findall function (documentation here).

Sample run

Here is an example file for testing: msg.txt

Here is how your program should work with this file (blue text is what your program should print, green text is what someone would type in):

roche@ubuntu$ python3 emails.py
filename: msg.txt
m273481@usna.edu
m257855@usna.edu
m281234@usna.edu
m280417@usna.edu
m274427@usna.edu
m266745@usna.edu
m253227@usna.edu

Submit command

To submit files for this homework, run one of these commands:

submit -c=sd212 -p=hw11 emails.py
club -csd212 -phw11 emails.py