'How do I get the results with the root resolved in python?

How do I get the results with the root resolved.

a = Eq(x**3 + x**2 - 3*x + 1,0)

b = solve(a)

print(b)

results:

[1, -1 + sqrt(2), -sqrt(2) - 1]


Solution 1:[1]

Use evalf:

In [4]: [s.evalf() for s in b]                                                                                                                 
Out[4]: [1.0, 0.414213562373095, -2.41421356237309]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Oscar Benjamin