assignment statements: lists vs. strings

Klaus Neuner klaus_neuner82 at yahoo.de
Mon Feb 2 10:50:01 EST 2004


Hello,

I would like to understand the reason for the following difference
between dealing with lists and dealing with strings: What is this
difference good for? How it is accounted for in Python slang?

Klaus

>>> string1 = "bla"
>>> string2 = string1
>>> string1 = string1 + "bla"
>>> string1
'blabla'
>>> string2
'bla'
>>> 

>>> list1 = [1,2]
>>> list2 = list1
>>> list1.append(1)
>>> list1
[1, 2, 1]
>>> list2
[1, 2, 1]
>>>



More information about the Python-list mailing list