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?
My guess is that you
On Wed, Sep 28, 2011 at 4:28 PM, Tim Roberts t...@probo.com wrote:
My guess is that you actually typed
p=3*a
instead of
p=2*a
That produces 45.
Or alternatively, that you used an interactive Python environment and
didn't clear i between runs.
ChrisA
--
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.
--
On Tue, Sep 27, 2011 at 10:21 AM, 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
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
I tried running your code in ipython:
In [1]: l = [1,2,3,4,5]
In [2]: i = 0
In [3]: for a in l:
...: p = 2 * a
...: t = p + i
...: i = t
...:
In [4]:
In [4]: t
Out[4]: 30
The output from Python was 30, not 45. What Python version are you
running?
On Sep 27, 6:21 pm,
On 09/27/2011 10:21 AM, sakthi 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.
I think
On Sep 27, 1:43 pm, Chris Rebert c...@rebertia.com wrote:
On Tue, Sep 27, 2011 at 10:21 AM, 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
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
I think you may be doing something wrong.
If I run:
l = [1, 2, 3, 4, 5]
i = 0
for a in l:
...i += 2 * a
...
i
30
The result is 30 as expected.
Nowhere near the 155 that you are getting. :/
Again, could you state which version of python are you using (and what
OS) so that we
On 9/27/2011 12:50 PM, sakthi said this:
On Sep 27, 1:43 pm, Chris Rebert c...@rebertia.com wrote:
On Tue, Sep 27, 2011 at 10:21 AM, 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
11 matches
Mail list logo