To convert a Python string to a list, use split(): "TX,CA,NY".split(",") gives ['TX', 'CA', 'NY'], and with no argument it splits on whitespace. To get one item per character, use list(text):
words = text.split() # list of words
chars = list(text) # list of characters
These snippets use US cities, state codes and prices, run on Python 3.12.5.
You’ll learn split() and list(), comma-separated values with spaces and numbers, strings that already look like a list, and multiple delimiters.
Convert a string to a list with split() and list()
split() with no argument treats any run of spaces as one separator. Pass a separator and it splits on exactly that, which can leave empty strings:
sentence = "Ship to Austin Texas today"
print(sentence.split()) # any run of whitespace
print(sentence.split(" ")) # exactly one space: note the empty string
print("TX,CA,NY,FL".split(","))
print("2026-10-10 09:30:00".split(" ", 1)) # maxsplit=1
print(list("Ohio")) # one item per character
Output:
['Ship', 'to', 'Austin', 'Texas', 'today']
['Ship', 'to', 'Austin', '', 'Texas', 'today']
['TX', 'CA', 'NY', 'FL']
['2026-10-10', '09:30:00']
['O', 'h', 'i', 'o']

split() collapses the double space; split(" ") keeps an empty string for it.maxsplit stops after that many splits, handy for a date and time. More whitespace cases are in splitting a string by whitespace in Python.
Split a comma-separated string into numbers or clean words
Data from a form or CSV usually has stray spaces. float() and int() ignore them, but for text, strip each piece:
raw = "19.99, 5.25 ,102.00, 7.50"
parts = raw.split(",")
print(parts) # spaces stay attached
prices = [float(p) for p in parts] # float() ignores the spaces
print(prices, "total:", f"${sum(prices):.2f}")
tags = [t.strip() for t in " python , data , web ".split(",")]
print(tags)
print("".split(","), "".split()) # empty string: [''] vs []
Output:
['19.99', ' 5.25 ', '102.00', ' 7.50']
[19.99, 5.25, 102.0, 7.5] total: $134.74
['python', 'data', 'web']
[''] []

strip(); an empty string splits into [''], not an empty list.That last line bites in real code: "".split(",") gives one empty item. Check for an empty string first. Converting each piece is covered in converting a string to an integer in Python.
How do you convert a string that looks like a list?
Sometimes the string is already "['Austin', 'Denver']", for example from a log or a CSV cell. ast.literal_eval() parses it safely. json.loads() only works with double quotes:
import ast
import json
text = "['Austin', 'Denver', 'Tampa']"
print(ast.literal_eval(text), type(ast.literal_eval(text)).__name__)
try:
json.loads(text)
except json.JSONDecodeError as err:
print("JSONDecodeError:", err.msg)
print(json.loads('["Austin", "Denver", "Tampa"]')) # JSON needs double quotes
Output:
['Austin', 'Denver', 'Tampa'] list
JSONDecodeError: Expecting value
['Austin', 'Denver', 'Tampa']

literal_eval returns a real list; JSON rejects the single quotes.Never use eval() for this; it runs any code in the string. If the data is JSON, I’d write it with json.dumps() in the first place, as in converting a string to CSV in Python.
Split a string with multiple delimiters using re
When the separators vary, re.split() takes a pattern. re.findall() pulls out only the parts you want, and splitlines() handles line breaks:
import re
line = "Austin;Denver, Tampa|Miami"
print(re.split(r"[;,|]\s*", line)) # several delimiters at once
print(re.findall(r"\d+", "Order A-1001 shipped 3 items, $49 total"))
print("line one\nline two\r\nline three".splitlines())
Output:
['Austin', 'Denver', 'Tampa', 'Miami']
['1001', '3', '49']
['line one', 'line two', 'line three']

Patterns are covered in more depth in splitting a string with regex in Python.
Which string to list method should you use?
Match the method to what your string looks like. If you need to go the other way later, see building strings from variables in Python.
| String | Use | Result |
|---|---|---|
| Words separated by spaces | s.split() | List of words |
| Values with one separator | s.split(",") | List of strings |
| Characters | list(s) | One item per character |
| Looks like a Python list | ast.literal_eval(s) | The real list |
| Mixed separators | re.split(pattern, s) | List of strings |
Keep going with these string guides:
- Iterate through a string in Python
- Split a long string into multiple lines
- Convert a tuple to a string in Python
- Convert a string to a byte array
Frequently asked questions
How do I convert a string to a list in Python?
Use s.split() for words, s.split(",") for comma-separated values, or list(s) for characters.
How do I convert a string to a list of characters?
Pass it to list(): list("Ohio") gives ['O', 'h', 'i', 'o'].
Why does split give empty strings?
With an explicit separator, each separator splits, so doubled separators leave ''. Use split() with no argument for whitespace.
How do I convert “[‘a’, ‘b’]” into a list?
Use ast.literal_eval(s). It safely parses Python literals; don’t use eval().
How do I convert a comma-separated string to integers?
[int(x) for x in s.split(",")]. int() ignores surrounding spaces.
Where is str.split documented?
See str.split() in the Python docs.

Bijay Kumar is a 13-time Microsoft MVP with more than 18 years in software development, and the founder of Python Guides and TSinfo Technologies. He started out building .NET and SharePoint solutions at HP, TCS and KPIT before moving into Python, machine learning and AI, and he also builds web apps with TypeScript and React. He writes the tutorials here himself, and every example is run before publishing so you see the real output. More about Bijay · Microsoft MVP profile · LinkedIn