Problem 23 (Python)