This is problem 7.4 from Rudin's real and complex analysis:
Suppose $f$ is a real Lebesgue measurable function with periods $s$ and $t$ whose quotient $s/t$ is irrational. Prove that there is a constant $c$ such that $f(x)=c$ almost everywhere.
Rudin gives a hint: Prove that for each $\lambda \in \mathbb{R}$ either the set $\{ x \in \mathbb{R} :f(x)>\lambda\}$ or its complement has measure $0$.
I have shown the hint, which I think is the hard part. However, I cannot manage to use it to prove the problem.
What I am trying to do is the following: Assume $f$ is not constant almost everywhere. Then, for each $\lambda \in \mathbb{R}$, the set $\{ x \in \mathbb{R} :f(x) \neq \lambda\}$ has positive measure. Now, I want to use the hint to prove that this is a contradiction but here is where I am stuck.
Any ideas on how should I proceed ?
Many thanks in advance!