CBSE Class 11 Computer Science Question 90 of 114

Tuples — Question 27

Back to all questions
27
Question

Question 3(k)

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

t = ( 'a', 'b', 'c', 'd', 'e') 
a, b, c, d, e, f = t
Answer
Output
ValueError: not enough values to unpack (expected 6, got 5)   
Explanation

In tuple unpacking, the number of elements in the left side of assignment must match the number of elements in the tuple.
Here, tuple t contains 5 elements where as left side contains 6 variables which leads to mismatch while assigning values.