CBSE Class 11 Computer Science Question 64 of 88

Tuples and Dictionary — Question 29

Back to all questions
29
Question

Question 14(f)

Consider the following code and find out the error:

t = (10, 20, 30, 40)
t[1] = 'o'
Answer

The code will result in an Error because tuples in Python are immutable. The line t[1] = 'o' attempts to modify the second element of the tuple, which is not allowed because tuples do not support item assignment.