Really basic problem
Ricardo Aráoz
ricaraoz at gmail.com
Mon Oct 8 10:35:27 EDT 2007
tomamil wrote:
> i know this example is stupid and useless, but that's not the answer
> to my question.
> here it goes:
>
> status = 0.0
> for i in range(10):
> status = status + 0.1
>
> if status == 0.1:
> print status
> elif status == 0.2:
> print status
> elif status == 0.3:
> print status
> elif status == 0.4:
> print status
> elif status == 0.5:
> print status
> elif status == 0.6:
> print status
> elif status == 0.7:
> print status
> elif status == 0.8:
> print status
> elif status == 0.9:
> print status
> elif status == 1.0:
> print status
>
> the expected output:
> 0.1
> 0.2
> 0.3
> 0.4
> 0.5
> 0.6
> 0.7
> 0.8
> 0.9
> 1.0
>
> but it gives me instead:
> 0.1
> 0.2
> 0.4
> 0.5
> 0.6
> 0.7
>
> why?
>
> thanks,
>
> m.
>
Replace : status = status + 0.1
with : status = round(status + 0.1, 1)
More information about the Python-list
mailing list