Hi, in this video we are going to discuss about sets in Python by another unordered unique collection of items and does not have indexing or slicing by unique collection of items, I mean like it cannot have any duplicate values, if we like pass on duplicate values within the set set function or we create a set it would not accept it or actually it will delete the duplicate values and only show unique values. So, it is generally used for mathematical set operations for instance you make union intersection, symmetric difference, etc. We can create set in Python by using curly braces. For example, let's create it. I underscore set Still, and one, comma b comma six, comma two. And let's pass on a duplicate value and see what it gives.
Why to get output cc 123 and six it did not repeat to twice. So it actually deleted the duplicate value and only printed out unique value. We can also create set by using set function for example E equals two set and we get a topple inside it. So, one comma three. Oh my God, my six let's print out a so it created a set. So these are the two ways we can create set.
If you're looking to create an empty set that's a bit tricky because when we go about creating an empty set, for example equals to be create a set of curly braces and not put anything else inside it and let's print out. So and when we check its type, for example. So it outputs a dictionaries, what it what it has done is it recognizes as a instead of empty said it recognized it as dictionary. Now in order to actually create a set an empty set, we can use a equals two Set. And when we type its check its type get do we get the output offset. So in order to create an empty set we generally use set function.
Set does not have indexing or slicing if he like. For example, we already have mindset we put on let's print out. So it is going to give an error. That object does not support indexing. It does not have any indexing. And we can add or update elements within set by using add method said doc In that and then I underscore set so it added four to it.
If we are looking to add multiple elements within the set, we can use update method and inside of update method we can like pipe pass on string integers tupple list or any other set as its argument to that to it. My talk update that's Barcelona double e dot was 6958 string A comma B are just a mistake, it does not take in teacher as its parameter, so just remove that. Let's check out this value. So you see 12345689, A and B. Okay, I hope now you have a better understanding by set. In the next video, we'll be discussing about set operations and built in functions.
Besides we'll be like doing set membership tests as well. So stay tuned. Thank you.