Solution in Python for Challenge138