CBSE Class 12 Computer Science Question 84 of 105

Python Revision Tour II — Question 11

Back to all questions
11
Question

Question 5(d)

Find the errors. State reasons.

t = 'hello'
t[0] = "H"
Answer

t[0] = "H" will raise an error because strings in python are immutable, meaning we cannot change individual characters in a string after it has been created. Therefore, attempting to assign a new value to t[0] will result in an error.