add( ) method :
The add( ) method inserts one element into the set
If the value is already present , it is ignored .
Python
fruits = {"apple", "banana"} fruits.add("mango") print(fruits) #output {'apple', 'banana', 'mango'} #order may changeupdate( ) method :
The update method can add multiple values from lists, tuples, another set etc.
Python
numbers = {1, 2, 3} numbers.update([4, 5, 6]) print(numbers) #output {1, 2, 3, 4, 5, 6} Add characters from String :
Python
s = set() s.update("python") print(s) #outout {'p', 'y', 't', 'h', 'o', 'n'}