Problem 32 in Python