Trivial Questions about Lie Algebra

I am new to Lie Algebra. Could someone help me to answer this question? thanks!

Question: how to prove for any non-abelian arbitrary lie algebra $L$, the dimension of it center $Z(L)$ is less or equal to dimension of $L-2$. i.e to prove $$dim(Z(L)) \leqslant dim(L)-2$$

The hint is to construct a contradiction by hypothesizing $$dim(Z(L)) \geqslant dim(L)-1$$

Could someone give me more suggestions or hints?

Thank you in advance!

Assume we do not have $\dim Z(L))\le n-2$. Then $\dim Z(L)=n-1$, because $L$ is non-abelian. Hence the center is a $1$-codimensional ideal in $L$, so that $L=Z(L)\oplus \langle x \rangle$, with some $x\in L$ satisfying $[x,y]=0$ for all $y\in L$. This implies $x\in Z(L)$, a contradiction.
There exists $x,y$ such that $[x,y]\neq 0$ $x,y$ are lin. ind. Suppose $dim(Z(L))=n-1$, $dim(Z(L))\cap Vect(x,y)\geq 1$. This implies there exists a non zero $ax+by\in Z(L),$ if $a\neq 0, [ax+by,y]=a[x,y]=0$. This implies $[x,y]=0$. contradiction. If $b\neq 0, [ax+by,x]=b[y,x]=0$. This implies $[x,y]=0$ contradiction. Thus $a=b=0$ and $ax+by=0$. Contradiction.