solution with python