updated ex6.py