Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
2. Recap
Tuples as return types in functions
Tuples as records
List of tuples


First, let's do a quick recap of tuple basics before we move on to their typical applications.


Tuples are a bit similar to lists, but they are immutable—once you create a tuple, you can't change it. Tuples frequently store values of multiple types. The codes below present basic tuple operations in Python.

  1. Define a tuple (name, age, nationality, city):
  2. person = ('Mark', 28, 'English', 'London')
  3. Access second element:
  4. person[1]
  5. Access second and third element:
  6. person[1:3]
  7. Iterate over tuple:
  8. for item in person:
  9. Check if tuple contains item:
  10. if item in person:
  11. Unpack tuple:
  12. name, age, nationality, city = person


Let's do a warm-up exercise! Write a function named print_adult_status(person) that accepts a tuple in the format shown in the template code. The function should check if the person is 18 years or older and print either:

{name} is of legal age.


{name} is not of legal age.

A person should have the following format:

(name, age, nationality, city)

Stuck? Here's a hint!

You will need to use person[0] (name) and person[1] (age) in your solution.