Python code which removes the reduntant brackets from a mathematical expression provided as a string