CoursePython from Scratch to Intermediate · Module 5: Collections · part 34 of 75
Part 34 · Module 5: Collections

Lesson 2: Tuples and sets, fixed records and unique values

16 min read·14 Oct 2026
Module 5 · Lesson 2 · About 45 minutes · Needs: Module 5 Lesson 1 (lists, indexing, slicing, append, len, loops over a list) and Module 1's multiple assignment

The situation

Amira leans on the counter with the twelve loans from Module 4. "What is out, and who has it? I want each name once." Six of the twelve loans have no return day:

THE SIX LOANS STILL OUT Jonah L04 Ben L13 Kwame L21 Lena L23 Priya L24 Kwame L28 6 loans, but only 5 people: Kwame twice
Six of the twelve loans are out, but only five people hold them: Kwame, in amber, appears twice.

Six loans, but five people: Kwame has two. A list keeps every repeat, so counting names in a list gives the wrong answer. This lesson adds a tuple, to hold one loan as a fixed record, and a set, to hold each name once.

The rest of this part opens with an account

Signing up is free and takes one email. Nothing to pay, and nothing renews.