In my python 3.2, no problem:
>>> l=[1,2,3,4,5]
>>> i=0
>>> for a in l:
... p=2*a
... t=p+i
... i=t
... print("p={}, t={}, i={}".format(p,t,i))
...
p=2, t=2, i=2
p=4, t=6, i=6
p=6, t=12, i=12
p=8, t=20, i=20
p=10, t=30, i=30
>>> t
30
>>>
paz e amor (love and peace),
Alysson Bruno
Palmas(TO)
Brasil
http://abruno.com
Leia: Heo Sargila: História da Criação:
http://heosargila.blogspot.com/2011/09/historia-da-criacao.html
2011/9/27 sakthi <[email protected]>
> In the following code,
> >>> l=[1,2,3,4,5]
> >>> i=0
> >>> for a in l:
> ... p=2*a
> ... t=p+i
> ... i=t
> ...
> >>> t
> 45
>
> 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.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list