a *= b not equivalent to a = a*b

Jussi Piitulainen jussi.piitulainen at helsinki.fi
Fri Aug 26 03:43:49 EDT 2016


mlzarathustra at gmail.com writes:

> Yes, I just worked that out. It's the integer math that's the problem.
>
> I guess this has been fixed in python 3 [- -]

Note that division in Python 3 produces approximate results (floating
point numbers). This may or may not be what you want in this exercise.
I would blame this problem entirely on the precedence issue and just do
the multiplication first. The algorithm is pretty neat that way.

(Meta) Also, please leave some relevant context so it's easier to follow
the discussion. It's a general principle, and particularly acute in
comp.lang.python where many messages fail to identify their parent.



More information about the Python-list mailing list