Multiplication error in python
clp2 at rebertia.com
Tue Sep 27 13:43:22 EDT 2011
On Tue, Sep 27, 2011 at 10:21 AM, sakthi <sakthi92 at gmail.com> 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.
My Python gives 30; methinks perhaps you've elided some important part
of your code.
Also, I note that your loop body can be significantly simplified to
just: i += 2*a
More information about the Python-list