- 1
Python : strings
please explain the following: Strings are also immutable, meaning that after a string is created, an individual characters of the string cannot be modified. provide example
2 ответов
+ 4
It means you can't change "homework" to "letothersdoitforme"
+ 1
You can create a string, by example:
s = "hello"
but you cannot modify an individual character, this generates an error:
s[1] = "a"
TypeError: 'str' object does not support item assignment
but it is possible to modify the complete chain:
s = "bye"
or
s = s[0] + "a" + s[2:]