From the course: Programming Concepts for Python
Unlock this course with a free trial
Join today to access over 24,500 courses taught by industry experts.
Add and remove items from sets - Python Tutorial
From the course: Programming Concepts for Python
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. (phone ringing) Oh, excuse me for a sec. Hey, Vern. What's up? Oh, you did? I'll call you back. That was my friend Vern. 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 plan to invite. Let's start by checking to see if Vern is already in the set of friends to invite and unfortunately, no. I must have taken him out of the set earlier. Well, since Vern 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 too 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…