Python set() Function
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 |