Computer Science

Consider the following code and find out the error:

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

Python Tuples

1 Like

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.

Answered By

2 Likes


Related Questions