Completed ex8.py