On Sep 27, 1:21 pm, sakthi <sakth...@gmail.com> wrote:
> 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.

You must be doing something different than these steps:

Python 3.2.2 (default, Sep  4 2011, 09:51:08) [MSC v.1500 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> l=[1,2,3,4,5]
>>> i=0
>>> for a in l:
        p=2*a
        t=p+i
        i=t


>>> t
30
>>>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to