[Tutor] converting string to float

Steven D'Aprano steve at pearwood.info
Thu Aug 11 01:20:36 CEST 2011


Shwinn Ricci wrote:

> however, I want to convert position to a floating point number, as the
> actual cell value is in the form of X.XXX (where X = digits). When I try
> float(position) I get a ValueError saying that the string could not be
> converted to a float. What am I doing wrong?

Inspect the string by printing it with repr() and see what is actually 
there.

e.g.

print repr(position)
float(position)



-- 
Steven



More information about the Tutor mailing list