Liste des Groupes | Revenir à cl c |
DFS <nospam@dfs.com> writes:I was surprised python did that, since every division used in the array addressing results in an integer.
[...]During conversion, I got a Python error I don't remember seeing in the past:[...]
>
"TypeError: list indices must be integers or slices, not float"
>
because division returns a float, and some of the array addressing was
like this: nums[i/2].
C's "/" operator yields a result with the type of the operands (after
promotion to a common type).
Python's "/" operator yields a floating-point result. For C-style
integer division, Python uses "//". (Python 2 is more C-like.)
Les messages affichés proviennent d'usenet.