THE WORLD'S LARGEST WEB DEVELOPER SITE

Python set() Function

❮ Built-in Functions


Example

Create a set containing fruit names:

x = set(('apple', 'banana', 'cherry'))
Run example »

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 Required. A sequence, collection or an iterator object

❮ Built-in Functions