Python set() Function

❮ Built-in Functions


Example

Create a set containing fruit names:

x = set(('apple', 'banana', 'cherry'))
Try it Yourself »

Definition and Usage

The set() function creates a set object.

The items in a set list are unordered, so it will appear in random order.

Read more about sets in the chapter Python Sets.


Syntax

set(iterable)

Parameter Values

Parameter Description
iterable Optional. A sequence, collection or an iterator object

❮ Built-in Functions

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.