answer 8 in python
answer 9 in python