python solution for problem 25