List is a mutable type, unlike strings
Dear members,
I'm a complete novice, finding my way throught the Pycharm Education Course.
I just came accros the following remark that I don't understand :
"You can add new items at the end of the list, by using the append() method and concatenation.
Unlike strings, lists are a mutable type,
i.e. it is possible to change their content using lst[index] = new_item "
I understand what is being said about information being added to a list.
But what I don't understand is the remark about a list being a MUTABLE type,
and a string NOT ....And in order to explain that statement, the example
is given saying " lst[index] = new_item ".
So saying ...
My_list[3] = "The value at the 4th position"
My_list[3] = "The value at the fourth position"
is being considered as a mutation,
but saying ...
Variable_my_text_string = 'Some value'
Variable_my_text_string = 'And now another value'
is NOT a mutation ?
I feel that I'm missing the point here..
Thx,
Kr,
请先登录再写评论。