Python (Fall 2026) Module 8-7: A8 Explanation
Watch on YouTube →
Overview
Bill Moseley explains the A8 email-extractor assignment by showing how to find candidate addresses in text and remove punctuation with Python string operations. He outlines three functions—extract emails, remove duplicates, and check list membership—and demonstrates how to test and troubleshoot them using the Abraham Lincoln and Taylor Swift starter text.
Key takeaways
- Python's str.find('@') returns the position of an at sign when present and -1 when absent, making it a straightforward way to identify candidate email words.
- String splitting can isolate candidate addresses, but punctuation attached to the word must be cleaned before returning results.
- Checking the last character with strWord[-1] and slicing the string provides one method for removing a sentence-ending period.
- The A8 extractor should return a list from a text-string input; the assignment also includes duplicate removal and list-membership checking.
- Testing against both Lincoln and Taylor Swift starter strings exposes edge cases, especially candidates with punctuation mixed into their beginning or end.
Chapters
0:00
Email Address Rules for Finding Valid Candidates
- Moseley identifies the @ sign as the first clue when searching web-page text for email addresses.
- Candidate addresses need text before and after @, a domain containing at least one period, and no trailing period.
- The examples distinguish email punctuation from sentence punctuation, such as the period after [email protected].
6:05
Use Python find, split, and Slicing to Clean Email Text
- Split a text string into words, then use strWord.find('@') to identify words containing an at sign; find returns -1 when it finds no match.
- Use strWord[-1] to inspect the last character and string slicing to remove a trailing period.
- Moseley also demonstrates reversing a string to inspect and slice its first character, emphasizing practice with string indexing and slicing.
11:28
Build and Test the A8 Extractor Functions
- The A8 starter materials include Lincoln and Taylor Swift text plus an A8 template containing two strings with embedded email addresses.
- The extractor should take a string, split it into words, find @ signs, clean surrounding punctuation, and return a list of email candidates.
- The assignment also calls for removing duplicates by converting a list to a set and back, and checking whether an email appears in a list.
- Moseley debugs the extractor by replacing temporary print statements with list appends; remaining challenge cases include illegal punctuation at the start or end of a candidate.
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Bill Moseley, Ph.D. - Computer Science Educator.