It's Autumn! Prices fall like leaves! - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Tuple basics
Tuples in functions
Summary
13. Summary

Instruction

It's time to wrap things up! First, let's have a quick review of what we've learned:

  1. Tuples may or may not be defined with parentheses, but they require commas:

    sample_tuple = 1, 2, 3
    another_tuple = (1, 2, 3)
    
  2. To access an element or a few of them, use square brackets:

    sample_tuple[1]
    sample_tuple[:2]
    
  3. To iterate over a tuple, use a for loop:

    for item in sample_tuple:
  4. To check if a tuple contains an element, use the in operator:

    if item in sample_tuple:
  5. You can unpack a tuple into a group of variables:

    number_one, number_two, number_three = sample_tuple
  6. You can return tuples from functions and precede a function parameter with an asterisk (*) if you want to allow a varying number of arguments:

    def function_name(*args):

All right, how about a short quiz now?

Exercise

Click Next exercise to continue.