rewrite ex20.py