ex21.py with extra credit