Assignment 3 (Python) Solution