Completed ex18.py