A set is an unordered collection data type with no duplicate elements. Sets are iterable and mutable. The elements appear in an arbitrary order when sets are iterated.
The elements of the set can not be duplicate. The elements of the python set must be immutable.
If we want to add single item to a list, we can use add()
method.
If we want to add more than one item to a list, we can use update()
method.
Add() method
Printing the element using for loop... Anmol Rakesh Prayag Sujeet Rahul Aimtocode Mukesh Pankaj
Here, in above example by using add() method
and adding one element Aimtocode.
update() method
Printing the element using for loop... Sujeet tutorial Rahul Python Mukesh Prayag Anmol Aimtocode Pankaj Rakesh
In above example, update() method
is used to add multiple elements.