write python code to solve