python version of question 8