Checkpoint 7.12.1.
- Wall
- Assignment is not allowed with strings.
- Call
- Assignment is not allowed with strings.
- Error
- Yes; strings are immutable.
What is printed by the following statements:
s = "Wall"
s[0] = "C"
print(s)
[]
operator on the left side of an assignment, with the intention of changing a character in a string. For example, in the following code, we would like to change the first letter of greeting
.Jello, world!
, this code produces the runtime error TypeError: 'str' object does not support item assignment
.greeting
. This operation has no effect on the original string.s = "Wall"
s[0] = "C"
print(s)