why do I get this behavior from a while loop?
S. Chris Colbert
sccolbert at gmail.com
Fri Nov 27 11:06:44 EST 2009
This seems strange to me, but perhaps I am just missing something:
In [12]: t = 0.
In [13]: time = 10.
In [14]: while t < time:
....: print t
....: t += 1.
....:
....:
0.0
1.0
2.0
3.0
4.0
5.0
6.0
7.0
8.0
9.0
In [15]: t = 0.
In [16]: time = 10.
In [17]: while t < time:
....: print t
....: t += 0.1
....:
....:
0.0
0.1
0.2
0.3
<--snip-->
9.4
9.5
9.6
9.7
9.8
9.9
10.0
I would think that second loop should terminate at 9.9, no?
I am missing something fundamental?
Cheers!
Chris
More information about the Python-list
mailing list