Python (Fall 2026) Module 9-4: Algorithms and Solving A8 Part 1
Watch on YouTube →
Overview
Bill Moseley explains why Assignment 8’s email extractor is an algorithmic challenge: a candidate must satisfy multiple structural and character rules, not merely contain an @ sign. He breaks the task into stages—identify likely candidates, split each candidate at @, reverse the first half to scan outward from the boundary, and keep only legal characters—then begins implementing the approach with Python’s `split()` and `[::-1]`.
Key takeaways
- A reliable email extractor must apply several independent rules: an @ sign with text on both sides, a period after @, and at least two characters following that period.
- Splitting a candidate at @ separates the address into local-part and domain-side strings, making their cleanup easier to reason about.
- Reversing the first half with Python’s `[::-1]` lets the program scan from the @ boundary toward the beginning, stopping at the first illegal character.
- The starter `findEmails` function identifies only probable candidates by searching space-separated words for @; it does not yet validate or clean them.
- `cleanEmail` is designed as a separate function that accepts one suspected address and returns a cleaned string, keeping candidate discovery distinct from cleanup.
Chapters
- Assignment 8 requires an @ sign with text on both sides, at least one period after @, and at least two characters after that period.
- Valid addresses cannot start or end with punctuation, contain spaces, or place a period at the beginning, end, or next to @.
- Moseley proposes splitting at @ and scanning each half outward from the boundary, stopping when a character is not allowed.
- The existing `findEmails` function splits input text on spaces into `liText` and collects words containing @ as probable email addresses.
- The candidate list can include extra surrounding characters, so `cleanEmail` is introduced to process one suspected address at a time.
- The cleanup plan is to divide each candidate into two halves and remove invalid characters from the outer ends.
- `strEmail.split('@')` creates a two-item `liEmail` list, with the first half at index 0 and the second half at index 1.
- The code assigns those list elements to separate strings so each side of the address can be cleaned independently.
- Python slice notation `[::-1]` reverses the first half, positioning its outer characters for a character-by-character scan from the @ boundary.
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.