completed python solution