4. Given Rt $\triangle A B C$ has two medians of lengths 3 and 4. Then the length of the third median is $\qquad$ .
4. $\sqrt{5}$ or $\sqrt{29}$.

Let the two legs of the right triangle $ABC$ be $a$ and $b$, and the hypotenuse be $c$. Then the lengths of the medians to the two legs are $\sqrt{\left(\frac{a}{2}\right)^{2}+b^{2}}, \sqrt{a^{2}+\left(\frac{b}{2}\right)^{2}}$, and the length of the median to the hypotenuse is $\frac{c}{2}$. According to the problem, we have:
(1) $\left\{\begin{array}{l}\frac{c}{2}=3, \\ \sqrt{\left(\frac{a}{2}\right)^{2}+b^{2}}=4, \\ a^{2}+b^{2}=c^{2}\end{array}\right.$
(2) $\left\{\begin{array}{l}\frac{c}{2}=4, \\ \sqrt{\left(\frac{a}{2}\right)^{2}+b^{2}}=3 \\ a^{2}+b^{2}=c^{2}\end{array}\right.$,
(3) $\left\{\begin{array}{l}\sqrt{\left(\frac{a}{2}\right)^{2}+b^{2}}=3, \\ \sqrt{a^{2}+\left(\frac{b}{2}\right)^{2}}=4, \\ a^{2}+b^{2}=c^{2} .\end{array}\right.$
Solving (1) gives $a^{2}=\frac{80}{3}, b^{2}=\frac{28}{3}$.

Thus, $\sqrt{a^{2}+\left(\frac{b}{2}\right)^{2}}=\sqrt{\frac{80}{3}+\frac{1}{4} \times \frac{28}{3}}=\sqrt{29}$.
Solving (2) gives $a^{2}=73 \frac{1}{3}, b^{2}=-\frac{28}{3}$ (discard).
Solving (3) gives $a^{2}=\frac{44}{3}, b^{2}=\frac{16}{3}$.
Thus, $\frac{c}{2}=\frac{1}{2} \sqrt{a^{2}+b^{2}}=\frac{1}{2} \sqrt{\frac{44}{3}+\frac{16}{3}}=\sqrt{5}$.
Therefore, the length of the third median is $\sqrt{29}$ or $\sqrt{5}$.