Skip to content
Built-in Functions

set()

Make a collection that keeps only unique items.

set(iterable=())

set() removes duplicate values from an iterable.

Sets do not keep a fixed order, so sort one before printing when order matters.

Parameters

NameDescription
iterableOptional value whose unique items should become set members.

Returns

A new set.

Try it

Run it and change it
letters = ["b", "a", "b"]
print(sorted(set(letters)))

Related entries