Let $G$ be a non-trivial finite group and $p$ a prime number. If every subgroup $H\leq$ G has index divisible by $p$, prove that the center of $G$ has order divisible by $p$.
So I have that $[G:H]=pk$ for some integer $k$, and we need to prove that $|Z(G)|=pl$ for some integer $l$. Let $|G|=n$, I can prove the case if assume $G$ is an abelian group, then $|Z(G)|=n$, so the center has order divisible by $p$.
How should I approach if $G$ is not abelian?