Given $G$ group and $H \le G$ such that $|G:H|=2$, how does $x^2 \in H$ for every $x \in G$?

I'm having some trouble understanding cosets.

If I understand it correctly, cosets form a partition. So, if I have $|G:H| = 2$, then $G = H \cup xH$. Right?

In an exercise, I'm asked the following:

"For $G$ group and $H \le G$ such that $|G:H| = 2$, prove that $x^2 \in H$ for any $x \in G$"

If $x \in H$, then $x^2 \in H$ because $H$ is a group. But, if $x \notin H$, then $x \in gH$ for any $g \in G$, right? Then $x^2$ = $(gh)^2$ but I can't see why this is in $H$.

Can you give me some hint? Thanks for stopping by.


If $x\not\in H$, then $x^2$ is in either $H$ or $xH$. If $x^2\in xH$ then $x^2=xh$ for some $h\in H$. But then $x=h\in H$.