float to string conversion

Julio Flores Schwarzbeck jflores at codeit.com
Mon Dec 18 14:54:26 EST 2000


Take a look at the following python snippet (key in from the python prompt)..

x=5.25
y="Bad Check"
print "Error for ammount %f, Error Message: %s" % (x, y)
print "Error for ammount %s, Error Message: %s" % (x, y)

Hope it helps.

Julio


At 07:00 PM 12/18/00 +0000, deragon at 8d.com wrote:
>Greetings.
>
>
>   I am embarrassed to ask this since it is trivial, but
>   I cannot figure out how to convert a float to a string (obviously,
>   I am new to python).  Somehow, I could not find in the 2.0
>   documentation the syntax to perform the operation.
>
>   The following in my function:
>
>     return MSISDN + " check FAILED:  $" + balance + errormsg
>
>   where balance is a floating number and errormsg is a string
>   generates the following error:
>
>     TypeError: cannot add type "float" to string
>
>
>Sincerely,
>Hans Deragon
>
>
>Sent via Deja.com
>http://www.deja.com/
>--
>http://www.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list