[Tutor] index elongated/decreased
Tim Peters
tutor@python.org
Sat, 10 Aug 2002 02:17:45 -0400
[Thomas Rivas]
> Hi progressing pythonistas--
Hi!
> Playing with the interpreter I came up with this:
>
> >>> a = [66.6, 333, 333, 1, 1234.5]
> >>> print a.count(333), a.count(66.6), a.count('y')
> 2 1 0
> >>> a.insert(2, -1)
> >>> a.append(333)
> >>> a
> [66.599999999999994, 333, -1, 333, 1, 1234.5, 333]
>
> Can anyone explain why 0th index came out as it did? Is this a
> floating point arithmetic issue/limitation? Thanks.
Indeed it is. A full explantion is here:
<http://www.python.org/doc/current/tut/node14.html>
Note that you can demonstrate the effect with less effort <wink>:
>>> 66.6
66.599999999999994
>>>