Sets are used to store multiple items in a single variable.
Set are one of four datatype in python
Set is collection which is unordered, unchangeable , and unindexed
Set are written between curly brackets
Example
set1 = {'mango' ,' banana', 'graps' , 'apple'}
set2 = {1, 50, 79}
set2 = {1, 50, 79}
set3 = {'mango' ,50, 'graps' , 1, 80}
Set items are unordered, unchangeable and allows to duplicate values
Unordered : unordered means do not define Order
Unchangeable : unchangeable means that items can not be change after set is create
Duplicate are not allowed : Set cannot has two items with the same value
Example
set = {'mango' ,' banana', 'graps' , 'apple', 'mango'}
print(set)
Output
{'graps', ' banana', 'mango', 'apple'}
Print set
print() function is used for print set
Example
set = {'mango' ,' banana', 'graps' , 'apple'}
print(set)
Output
{mango' ,' banana', 'graps' , 'apple'}