Computer Science
Find the output generated by following code fragments :
(a, b, c, d) = (1, 2, 3)
Python Tuples
2 Likes
Answer
Output
ValueError: not enough values to unpack (expected 4, got 3)
Explanation
Tuple unpacking requires that the list of variables on the left has the same number of elements as the length of the tuple. In this case, the list of variables has one more element than the length of the tuple so this statement results in an error.
Answered By
1 Like
Related Questions
Find the output generated by following code fragments :
plane = ("Passengers", "Luggage") plane[1] = "Snakes"
Find the output generated by following code fragments :
(a, b, c) = (1, 2, 3)
Find the output generated by following code fragments :
a, b, c, d = (1, 2, 3)
Find the output generated by following code fragments :
a, b, c, d, e = (p, q, r, s, t) = t1