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

Instruction

Good job! We mentioned that tuples are often used to represent real-world objects. Because we typically have multiple objects in any IT system, we need a way of keeping them together. That's why we often create lists of tuples. Take a look:

cars_to_sell = [
  ('Volvo', 18000, 137000),
  ('BMW', 23000, 80000),
  ('Opel', 12000, 75000),
  ('Ford', 14500, 100000)
]

In the list above, each element is a tuple that represents a single car to sell.

Exercise

Create a list named new_hires that will contain three tuples, each representing a single new employee. Each tuple should have three elements: the employee's name, position, and monthly salary. Include the following people:

  1. Mark Adams, an SQL Analyst who earns $4,000
  2. Leslie Burton, an HR Specialist who earns $2,300
  3. Dorothy Castillo, a UX Designer who earns $3,100

Stuck? Here's a hint!

The first tuple should look like this:

('Mark Adams', 'SQL Analyst', 4000)