Ask Your Question

Revision history [back]

This works for me:

x = float(42.44444)
print("all {2:.3f} good {0} eat {1}".format("dogs","shoes",x))

With your code, x is not a float:

x = 42.44444
sage: type(x)
<type 'sage.rings.real_mpfr.RealLiteral'>

I guess not all aspects of Python's format are implemented for this type of object. Perhaps it passes the string representation of x to format, which is what leads to the error message.