SD 212 Spring 2023 / Homeworks


This is the archived website of SD 212 from the Spring 2023 semester. Feel free to browse around; you may also find more recent offerings at my teaching page.

hw11: Midshipman email addresses

  • Due before the beginning of class on Friday, 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.

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