python solution for problem 21