Change value of element in list

Rony Steelandt bucodi at yahoo.fr.invalid
Mon Jun 19 03:52:11 EDT 2006


> Hi,
>
> I'm doing python tutorial,
>> http://docs.python.org/tut/node5.html
>
> and I have these,
>
> lists = ['spam', 'eggs', 100, 1234]
> lists[2] = lists[2] + 23
>
> I expected this,
> lists = ['spam', 'eggs', 123, 1234]
>
> but got this,
> lists = ['spam', 'eggs', 100, 1234]
>
> What's my problem here ?
>
> I have Fedora C5 with python2.4.
>
> Thanks.
>
> O Plameras

Don't think so
Microsoft Windows XP [version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrateur>python
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] 
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> list=['spam','egg',100,1234]
>>> list
['spam', 'egg', 100, 1234]
>>> list[2]=list[2]+23
>>> list[2]
123
>>> list
['spam', 'egg', 123, 1234]
>>>

Rony

-- 
---
Rony Steelandt
BuCodi
rony dot steelandt (at) bucodi dot com

Visit the python blog at http://360.yahoo.com/bucodi





More information about the Python-list mailing list