Python set() Function

Instance

Create a set containing fruit names:

x = set(('apple', 'banana', 'cherry'))

Running Instance

Definition and Usage

The set() function creates a set object.

The items in the collection list are unordered, so they will appear in a random order.

Please refer to the 'Python Collections' chapter for more information about collections.

Syntax

set(iterable)

Parameter Values

Parameters Description
iterable Required. A sequence, set, or iterator object.