Checkpoint 3.7.1.
- Ball
- 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 = "Ball"
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 = "Ball"
s[0] = "C"
print(s)