The insert() method adds a new element at the end of the set.
Example
insert() Syntax
The syntax of the set insert() method is:
set.insert(newElement)
Here, set is an object of the set class.
insert() Parameters
The insert() method takes a single parameter:
- newElement - element to be added to set
insert() Return Value
The insert() method doesn't return any value. It only updates the current set.
Example: Swift set insert()
Output
["C", "Java", "Swift", "C++"] [44, 21, 12, 35]