What is the difference between the two statements?
(i) t=(‘a’,’b’,’c’)
(ii) a,b,c=t
Answer:
The difference between the two statements is:
- The first statement (i) creates a tuple with three elements (‘a’, ‘b’, and ‘c’) and assigns it to a variable t.
- The second statement (ii) unpacks the tuple t and assigns its elements to three variables a, b, and c. Unpacking is a way of assigning multiple values to multiple variables in one line of code.