Syntax

Python Split a String Syntax

In Python, split a string: splits a string into a list — "a,b".split(",")

Quick Answer

Syntax
"a,b".split(",")
PythonSyntax

Split a String

Code example
"a,b".split(",")

Splits a string into a list.

Learn More

How to split a string in Python

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

Python Split a String Syntax

Use "a,b".split(",").

Related Syntax References

Frequently asked questions

What is the Python syntax for split a string?

Use this pattern: "a,b".split(",")

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