Completed problem 8 (008.py)