I was so fixed in the string format, that I was ignoring the basic math! =/
Thanks to everyone for the tips!! This solve very well: "%i.%02i" % divmod(348,100) Em quinta-feira, 29 de novembro de 2012 09h12min39s UTC-2, Joe Barnhart escreveu: > > Bzzzt! Thanks for playing! > > You get 3.0 for your result. (I'm not a python genius but I keep an > interpreter handy just to type in stuff and see what I get.) > > > >>> round(int("348")/100,3) > 3.0 > > > In your example, you rounded the result AFTER the integer division of > 348/100. But the result of the integer division was 3, so your rounded > version is 3.0. > > On Thursday, November 29, 2012 2:02:29 AM UTC-8, Manuele wrote: >> >> Il 29/11/12 10:49, Joe Barnhart ha scritto: >> >> Hmmm... >> >> That would give "3" since Python 2.x keeps the calculation as integer >> (it won't coerce it to a float). >> >> He could do a=int(a)/100.0 But that puts it into a floating point >> value, and rounding sometimes gives surprising and unexpected results. >> >> my 2 cent... >> >> a = round(int(a)/100, 3) >> >> M. >> > --