The sum of the degrees of all the vertices is twice the number of edges (\(e\)):
\[\sum_{i} d(v_i) = 2e \]
Suppose there was a vertex with a degree of 3. Then the total sum would be an odd number, since:
\[\begin{gather} \text{odd } + \text{even } = \text{odd} \\ \text{even } + \text{even } = \text{even} \\ \text{odd } + \text{odd } = \text{odd} \end{gather} \]
But since \(2e\) is an even number, there is a contradiction. However, if there was another vertex with some odd degree, like let's say 5, then the total sum would be even again.
Similarly, if there are odd number of vertices with odd degrees, then the total sum would be odd, which would lead to a contradiction. This the number of vertices with odd degrees has to be even.