Skip to content
dreamcode
dreamcode
Map
Sets & tuples
Lesson 34 of 77
+15 XP on finish
PYTHON INTERMEDIATEChapter 6 · Comprehensions and data tools

Sets and tuples

A tuple is an immutable list written with parentheses (). A set is an unordered collection of unique elements written with curly braces {}.

Worked example

How it reads

  • point = (10, 20) defines an immutable tuple
  • {"wispy", "puffy", "wispy"} creates a set, filtering out duplicates
Cloud tip: Use sets when checking membership or removing duplicates, and tuples for structured coordinates or records.
main.py
PYTHON
real Python, runs in your browser
Console
Run your code to see its output here.
YOUR TURN

Print how many unique items there are (3), then whether 4 is in the set (False).

Press Run to check your work.