Skip to content
← Python for AI/ML · all 50 levels

Sets

Level 26 of 50 · Data structures

Level 26 of 50

Sets

explained with a trip list. Watch the reel, then work through it below: run the code, take the quiz, keep the cheat sheet.

📒 Open the cheat sheet
SanaBilal wrote Murree TWICE on our trip list!
TeacherPython fixes that for free! Meet the set!
trip.py
trip = {"Murree",
        "Naran",
        "Murree"}
print(len(trip))
TeacherCurly brackets make a set. Now count it!
SanaWait, 3 places, but only 2?
TeacherSets keep only UNIQUE items! The second Murree just vanishes!
trip.py
trip = {"Murree", "Naran"}
print("Swat" in trip)
TeacherAnd checking with in is super fast. Is Swat on the list? Nope!

⏸ Pause & predict: what prints?

nums = {1, 2, 2, 3, 3}
print(len(nums))

Where this leads

Python is step one. Building AI that ships is the rest.

The diploma takes you from zero to deployed computer vision, LLM and agent projects, with engineers who build them for a living. Already code? The bootcamp does it in three months.