Computer Science
Consider the following code and find out the error:
t = (10, 20, 30, 40)
t[1] = 'o'
Python Tuples
2 Likes
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
Consider the following code and find out the error:
t1 = (10, 20, 30, 40) X, Y, Z = t1Consider the following code and find out the error:
tup1=('A', 'school', 10.5, 70) print max(tup1)Consider the following code and find out the error:
T1 = ('A') T2 = ('B', 'C', 3) T3 = T1 + T2Consider the following code and find out the error:
T1 = (10, 20, 30, 40) T2 = (40, 50, 60) T1, T2, T3 = T1, T2