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'}



Quiz Level 1

Quiz Level 2


Request Me




 

Comments

Popular posts from this blog

How To Create .ENV File in Python

Create a Large file for Test Data Processing using Python

How to solve the Liner Equation using Python