python solution for problem 26
python solution for problem 27