Sets


add()

The set add() method adds a given element to a set. If the element is already present, it doesn't add any element.

The syntax of set add() method is:
set.add(elem)

Example:-
vowels = {'a', 'e', 'i', 'u'}
vowels.add('o')
print('Vowels are:', vowels)

Output:-
Vowels are: {'a', 'i', 'o', 'u', 'e'}

 

add()

The set add() method adds a given element to a set. If the element is already present, it doesn't add any element.

The syntax of set add() method is:
set.add(elem)

Example:-
vowels = {'a', 'e', 'i', 'u'}
vowels.add('o')
print('Vowels are:', vowels)

Output:-
Vowels are: {'a', 'i', 'o', 'u', 'e'}