13.2. Tuple PackingΒΆ

Wherever python expects a single value, if multiple expressions are provided, separated by commas, they are automatically packed into a tuple. For example, we can omit the parentheses when assigning a tuple of values to a single variable.

Check your understanding

2. Create a tuple called practice that has four elements: β€˜y’, β€˜h’, β€˜z’, and β€˜x’.

3. Create a tuple named tup1 that has three elements: β€˜a’, β€˜b’, and β€˜c’.

4. Provided is a list of tuples. Create another list called t_check that contains the third element of every tuple.

5. Below, we have provided a list of tuples. Write a for loop that saves the second element of each tuple into a list called seconds.

You have attempted 1 of 7 activities on this page