[Tutor] float & string

Terje Johan Abrahamsen terjeja@hotmail.com
Wed, 29 May 2002 21:37:26 +0000


I have a floating number (240.00) that I want to make into a string, so I 
can add a character to the end of it. But, the string doesn't become 240.00, 
but 240.000000. How can I make sure that the string stays like a dollar 
amount?

Thanks in advance,
Terje

------
Here is a part of the code:

a = accountcurrents.xlamount # the stringvar with the dollar amount.
        accountcurrents.xlamount = string.atof(a) #conv to float
        round(accountcurrents.xlamount, 2) #round to 2 digits
        if accountcurrents.xlamount < 0: #if negative add '-' behind
            char = '-'
        else:
            char = ''

        accountcurrents.xlamount = "%f%s" % (abs(accountcurrents.xlamount), 
char) #here the - gets added, and it becomes a string

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx