From the course: Programming Foundations: Real-World Examples

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Add and remove items from sets

Add and remove items from sets - Python Tutorial

From the course: Programming Foundations: Real-World Examples

Start my 1-month free trial

Add and remove items from sets

- Now I think I'm finally done sorting through my friends. I finalized my set, and I'm ready to start inviting people. (cellphone rings) Oh! Excuse me for a sec. Hey Verne, what's up? Oh you did? Um, I'll call you back. That was my friend Verne, he heard a rumor that I'm planning a game night, and wanted to know if he and Jim could join. I'd love to invite them. They are really good friends. Here's the set of friends that I planned to invite. Let's start by checking to see if Verne is already in the set of friends to invite. And unfortunately no. I must have taken him out of the set earlier. Well, since Verne really wants to hang out, I'll be a good friend and add him back to the set of friends to invite. But that raises a problem. Now I have one to many people in my set of friends to invite. So I'm going to need to remove somebody. - Hey, I was just chatting with Nestor online. It turns out he's in Romania this week. - Well I think it's safe to assume that Nestor won't be making it…

Contents