Syntax

Python Create a Set Syntax

In Python, create a set: creates a collection of unique items — s = {1, 2, 3}

Quick Answer

Syntax
s = {1, 2, 3}
PythonSyntax

Create a Set

Code example
s = {1, 2, 3}

Creates a collection of unique items.

Learn More

How to create a set in Python

  1. Open your Python file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Python Create a Set Syntax

Use s = {1, 2, 3}.

Related Syntax References

Frequently asked questions

What is the Python syntax for create a set?

Use this pattern: s = {1, 2, 3}

Can I copy this Python code example?

Yes. Use Copy code and adapt the example to your program.

Is this Python syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify