Solve 38 in Python