more elegant solution

added python solution