I'm trying to solve the below exercise.

Let $f:[0,1]\to [0,1]$ be a continuous function. Prove that $f$ has at least one fixed point: an $a\in A$ such that $f(a)=a$. Is the same true for discontinuous functions?

Here is my attempt.

Notice that if $f(0)=0$ or $f(1)=1$, the theorem is proved. Suppose not. Define $g(x)=f(x)-x$, which is a continuous function from $[0,1]$ to $[0,1]$. Then since $f(0)\ne 0$, $g(0)\ne 0$, so $g(0)>0$. Since $f(1)\ne 1$, $g(1)<0$. By the intermediate value theorem, there exists $a\in [0,1]$ such that $g(a)=0$. So $f(a)-a=0$, so $f(a)=a$.

I am fairly sure that the result is not true for discontinuous functions, largely because I requiblack continuity of $g$ to invoke the intermediate value theorem. I am having trouble finding a counterexample, however. Do I define a function piece-wise, with jumps at $x=0$ or $x=1$, to try to break the intermediate value theorem?