solution in python