python solution