Primary
set() ⚬ᵖʸ|Documentation|1st|20251021010041-00-⌔
Built-in Types — Python 3 documentation#set
class
set(iterable=(),/)class
frozenset(iterable=(),/)Return a new set or frozenset object whose elements are taken from iterable. The elements of a set must be hashable. To represent sets of sets, the inner sets must be
frozensetobjects. If iterable is not specified, a new empty set is returned.Sets can be created by several means:
- Use a comma-separated list of elements within braces:
{'jack', 'sjoerd'}- Use a set comprehension:
{c for c in 'abracadabra' if c not in 'abc'}- Use the type constructor:
set(),set('foobar'),set(['a', 'b', 'foo'])Instances of
setandfrozensetprovide the following operations:Printed 2026-06-28.
Link to original
Secondary
• • •