In Day 23, we go hands-on with set operations and methods — the stuff you actually use in real programs. What you'll learn in this lesson: Iterating through a set using for loop Checking membership using in and not in Adding elements using add() Why set items must be hashable and immutable Adding tuples to a set (and why lists fail) Combining sets using update() Updating sets using iterables (list/tuple) Removing elements using: remove() (throws error if missing) discard() (safe removal) pop() (random removal) Clearing all items using clear() Deleting an entire set using del Joining sets using union() Sets are built for speed and uniqueness. If you're still using lists for membership checks, you're leaving performance on the table. ======================HOME ASSIGNMENT====================== 1️⃣ Membership Muscle Memory Create a set of numbers. Check if a specific number exists Check if another number does not exist Print proper messages (not just True/False) 2️⃣ Add with Awareness Create an empty set. Add an integer Add a float Add a string Add a tuple Then try adding a list and observe the error. 👉 Write one comment: Why does Python reject lists in sets? This builds deep understanding, not fear of errors. 3️⃣ Update Like a Pro Create two sets: a = {10, 20, 30} b = {30, 40, 50} Tasks: update a using b update a using a list [60, 70] print a after each step 4️⃣ remove() vs discard() (Very Important 🔥) Create a set with 4 items. Remove one existing item using remove() Try removing the same item again (see error) Now do the same with discard() Explain in one line: Which method is safer and why? 5️⃣ Pop Reality Check Create a set. Use pop() twice Print removed values 👉 Observe: order is unpredictable. That’s the point. Sets don’t care about order. 🔥 Mini Project (Must Do) Unique Course Enrollment System enrollments = ["Amit", "Riya", "Amit", "Karan", "Riya", "Neha"] Tasks: total enrollments (list length) unique students (convert to set) add a new student remove a student safely Print final enrollment list. __________________________________________________________________________ #PythonInHindi #PythonBasics #LearnPython #ProgrammingInHindi