Python Programming - Variables - Discussion

Discussion Forum : Variables - General Questions (Q.No. 20)
20.
What is the output of the following code:
my_string = "hello"
my_string[1] = "a"
print(my_string)
hello
hallo
An error is raised
None of the above
Answer: Option
Explanation:

In Python, strings are immutable, which means their individual characters cannot be modified once they're created.

Attempting to change a character of a string using the index operator [ ] results in a TypeError.

Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.