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
[color=blue][color=green][color=darkred]
>>> string1 = "bla"
>>> string2 = string1
>>> string1 = string1 + "bla"
>>> string1[/color][/color][/color]
'blabla'[color=blue][color=green][color=darkred]
>>> string2[/color][/color][/color]
'bla'[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
[color=blue][color=green][color=darkred]
>>> list1 = [1,2]
>>> list2 = list1
>>> list1.append(1)
>>> list1[/color][/color][/color]
[1, 2, 1][color=blue][color=green][color=darkred]
>>> list2[/color][/color][/color]
[1, 2, 1][color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
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
[color=blue][color=green][color=darkred]
>>> string1 = "bla"
>>> string2 = string1
>>> string1 = string1 + "bla"
>>> string1[/color][/color][/color]
'blabla'[color=blue][color=green][color=darkred]
>>> string2[/color][/color][/color]
'bla'[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
[color=blue][color=green][color=darkred]
>>> list1 = [1,2]
>>> list2 = list1
>>> list1.append(1)
>>> list1[/color][/color][/color]
[1, 2, 1][color=blue][color=green][color=darkred]
>>> list2[/color][/color][/color]
[1, 2, 1][color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
Comment