Problem 26 in Python