While Statement
Andreas Tawn
andreas.tawn at ubisoft.com
Fri May 22 06:51:03 EDT 2009
> Im using 2.6 python and when running this
>
> class progess():
>
> def __init__(self, number, total, char):
>
> percentage = float(number/total*100)
> percentage = int(round(percentage))
> char = char * percentage
> print char
>
> progess(100, 999, "*")
>
> the "percentage = float(number/total*100)" always equals 0.0
Try percentage = float(number)/total*100 # The closing bracket position
is the important one
The problem is that you're converting to float after the int division
damage has been done.
Cheers,
Drea
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090522/71a182a0/attachment-0001.html>
More information about the Python-list
mailing list