The built-in add()
method in Python is used to add an element to a set.
set.add(element)
This method requires one element to be passed as a parameter. If that element already exists in the set, it won’t be added.
It is important to note that this method only returns None
. Instead of returning a value, it adds an element to the set that calls the method.
x = {'Cats', 'Dogs', 'Elephants', 'Seals'}x.add('Tiger')print(x)