CBSE Class 12 Computer Science Question 83 of 105

Python Revision Tour II — Question 10

Back to all questions
10
Question

Question 5(c)

Find the errors. State reasons.

t = [1, "a", 9.2]
t[4] = 6
Answer

t[4] = 6 will raise an error as we are trying to change the value at index 4 but it is outside the current range of the list t. As t has 3 elements so its indexes are 0, 1, 2 only.