SD 212 Spring 2024 / Homeworks


hw11: Midshipman email addresses

  • Due before the beginning of class on Friday, February 2

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.

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
m253481@usna.edu
m237855@usna.edu
m261234@usna.edu
m260417@usna.edu
m254427@usna.edu
m246745@usna.edu
m233227@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