Refactored Python solution to Challenge 128 [Intermediate]