Multiplication error in python
gherron at digipen.edu
Tue Sep 27 19:41:02 CEST 2011
On 09/27/2011 10:21 AM, sakthi wrote:
> In the following code,
>>>> for a in l:
> ... p=2*a
> ... t=p+i
> ... i=t
> Python gives an answer as 45. But i am getting 30 when i execute
> manually. Is there any different multiplication pattern in python?
> Thank yu.
I think it's most likely you've made an error here. Running your exact
lines in Python gives the expected result:
>>> for a in l:
Please try again. If you can reproduce the incorrect result -- then we
have a real bug. However, the chance of that is really really tiny.
Gary Herron, PhD.
Department of Computer Science
DigiPen Institute of Technology
More information about the Python-list