From the course: Python Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Tuples and sets

Tuples and sets

- [Instructor] Alright, let's take a deeper dive into two data structures we've covered only briefly before. We're talking about tuples and sets. But first, let's talk about sets. Remember, a set is declared using curly brackets, like so, {'a', 'b', 'c'}, mySet. There we go, it has those curly brackets. You can also define it by passing any sort of iterable object in the constructor of the set class. So mySet, and here we have a set object constructor. And then you can do, {'a', 'b', 'c'}, same exact thing or you could even use a tuple in here. So here we're passing a tuple with A, B, and C in there and we still get the same set. One common pattern in programming is to remove duplicates from a list. Well, because you can convert a list to a set and then back again and sets can only contain unique values this becomes pretty easy. So let's make a list that has some duplicate values in it B, C, C, or let's make that a C.…

Contents