Set Data Type in Python
Concept
Set a collection which is unordered, unindex.
Set does not allow duplicate data.
Code Example
Example 1:
>>> s = {'A', 'B', 'C', 'D'}
>>> type(s)
<class 'set'>
>>> s = {'A', 'B', 'C', 'D'}
{'B', 'D', 'A', 'C'}
>>> s.add('New')
>>> s
{'B', 'HH', 'D', 'A', 'C'}
>>> s.update(['XX', 'YY'])
>>> s
{'YY', 'XX', 'B', 'HH', 'D', 'A', 'C'}
Comments
Post a Comment