Python Code To Flatten Something