Determining whether a piecewise function is odd or even

A piecewise function is defined by $f(x)=-1$ in the interval $ -\pi\lt x \lt 0$ and $f(x)=1$ in the interval $ 0\lt x \lt \pi$. I've been taught that you can check whether the function is even or odd by replacing $f(x)=f(-x)$ if the function remains unchanged then it is even and if $f(-x)=-f(x)$ i.e. negative sign can be taken common then the function is odd. But in this case I am confused because by replacing $f(x)=f(-x)$ the function remains unchanged hence it should be even but I've been told this function is odd


It doesn't remain unchanged. If $x\in(-\pi,0)$, then $f(-x)=1$, since $-x\in(0,\pi)$. And, if $x\in(0,\pi)$, then $f(-x)=-1$, since $-x\in(-\pi,0)$. So, $f$ is indeed odd.