problem40 Python