What is tuple packing?
A tuple is one of 4 built-in collection data types and the other three are list, set, dictionary.
We can only apply two methods to tuple aa it is immutable. We saw everything in detail about tuple in the previous article, now let us see what is packing?
In tuple packing, we assign tuple items to a single variable or we assign multiple items to multiple variables and at the end, we assign all those multiple items to a single variable.
We have taken 4 variables a, b, c and d and in those variables, we have passed data, and all those 4 variables we passed to t4. And in this way, we achieve tuple packing.
What is tuple unpacking?
This is completely the opposite of tuple packing in this we assign each element of a tuple into different variables explicitly.
Here we have defined a tuple variable t2 and passed tuple items to it and then we have applied the concept of unpacking to it, that is the first item goes to a variable second item goes to the b, and so on. And this is how we achieve tuple unpacking.