Completed ex6.py