CBSE Class 11 Computer Science Question 80 of 114

Tuples — Question 17

Back to all questions
17
Question

Question 3(a)

Carefully read the given code fragments and figure out the errors that the code may produce.

t = ('a', 'b', 'c', 'd', 'e')  
print(t[5])
Answer
Output
IndexError: tuple index out of range 
Explanation

Tuple t has 5 elements starting from index 0 to 4. t[5] will throw an error since index 5 doesn't exist.