If you print ans, you will see that the result of solve is:
[x == (3/2),x == 8]

When you do ans[0].rhs(), you are grabbing the right hand side of the first statement. To get the second one, do ans[1].rhs().