Loading...
Python

set DataType

It is used to represent a group of values without duplicates, where order is not important then set data Type is used.

  1. Insertion order is not preserved.
  2. Index concept is not applicable.
  3. Heterogeneous objects are allowed.
  4. Duplicates are not allowed.
  5. Growable in nature.
  6. It is mutable collection.

Example:

s={100,0,10,300,50,’Webnoid’}
s#{0,100,’Webnoid’,300,10}
s[0]==>TypeError: ‘set’ object does not support indexing

set is growable in nature, based on our requirement we can increase or decrease the size.

>>>s,add(60)
>>>s
{0,100,’Webnoid’,300,10,60}
>>>s.remove(100)
>>>s
{0,’Webnoid’,300,10,60}

 

Leave a Reply

Your email address will not be published. Required fields are marked *