Python : strings | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 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

1st Jul 2021, 7:17 PM
Ricardo Morales
2 Answers
+ 4
It means you can't change "homework" to "letothersdoitforme"
1st Jul 2021, 8:03 PM
Oma Falk
Oma Falk - avatar
+ 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:]
1st Jul 2021, 7:34 PM
Monica Garcia
Monica Garcia - avatar