Computer Science

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

t = ( 'a', 'b', 'c', 'd', 'e') 
1, 2, 3, 4, 5, = t

Python Tuples

3 Likes

Answer

Output
SyntaxError: cannot assign to literal 
Explanation

When unpacking a tuple, the LHS (left hand side) should contain a list of variables. In the statement, 1, 2, 3, 4, 5, = t, LHS is a list of literals not variables. Hence, we get this error.

Answered By

2 Likes


Related Questions