Set is a collection containing only unique elements.
Insertion is done via the add
function. Like in the following example:
Output:
Notice that Tokyo
is contained only once, since no duplicates are allowed.
Size is the count of Set's elements. It's accessed via the len
function.
Output:
Certain values can be removed via the remove
function.
Output:
A value can be checked if contained via the in
keyword.
Output:
It can be iterated via for in
loop:
Output: