Completed ex12.py