Chapters
Python114 chapters

ReferenceSet methods

set.add()

Adds one item, doing nothing if it is already there.

Signature

collection.add(item)

Parameters

NameMeans
itemmust be hashable

Returns

None.

Example

Python
tags = {"python"}
tags.add("tutorial")
tags.add("python")
print(sorted(tags))

Output

['python', 'tutorial']

See also