- ✕This summary was generated using AI based on multiple online sources. To view the original source information, use the "Learn more" links.
The split() method in Python is used to split a string into a list of substrings based on a specified separator. If no separator is provided, the default separator is any whitespace.
Example
text = "Hello, world!"words = text.split()print(words) # Output: ['Hello,', 'world!']Copied!✕CopyUsing a Custom Separator
You can specify a custom separator to split the string.
text = "apple,banana,cherry"fruits = text.split(',')print(fruits) # Output: ['apple', 'banana', 'cherry']Copied!✕CopyLimiting the Number of Splits
The maxsplit parameter allows you to limit the number of splits.
text = "apple,banana,cherry"limited_fruits = text.split(',', 1)print(limited_fruits) # Output: ['apple', 'banana,cherry']Copied!✕CopyNote: The split() method is very useful for parsing and extracting data from strings.
Python String split () Method - W3Schools
Definition and Usage The split() method splits a string into a list. You can specify the separator, default separator is any whitespace.
See results only from w3schools.comTry It Yourself
The W3Schools online code editor allows …
W3Schools Tryit Editor
The W3Schools online code editor allows …
Python Dictionaries
As of Python version 3.7, dictionaries are …
Python Functions
Python Functions A function is a block of …
Java String Split
Definition and Usage The split() method …
Python Strings
Strings Strings in python are surrounded …
Python Lists
List Lists are used to store multiple items …
Python Data Types
Built-in Data Types In programming, data …
Remove List Duplicates
Create a Function If you like to have a …
Python Operators
Python Operators Operators are used to …
Python String split() - GeeksforGeeks
Apr 2, 2025 · Hope this tutorial on the string split () method helped you understand the concept of string splitting. split () method in Python has …
Split a String in Python (Delimiter, Line Breaks, Regex)
- The splitlines()method splits a string by line boundaries. 1. str.splitlines() — Python 3.11.4 documentation As shown in the previous examples, split() and rsplit() split the string by whitespace, including line breaks, by default. You can also specify line breaks explicitly using the sep argument. However, using splitlines()is often more suitable....
How to Split a String in Python
Feb 5, 2025 · This tutorial will help you master Python string splitting. You'll learn to use .split (), .splitlines (), and re.split () to effectively handle …
Python Line Split: A Comprehensive Guide - CodeRivers
Apr 13, 2025 · This blog post will delve deep into the concept of Python line split, covering the fundamental ideas, different usage methods, common practices, and best practices to help you …
How to Split a String in Python: A Comprehensive Guide
2 days ago · How to Split a String in Python: A Comprehensive Guide String manipulation is a cornerstone of programming, and splitting strings is one of the most common tasks you’ll …
- People also ask
5 Best Ways to Split a String in Python [+Examples]
Oct 7, 2024 · Python's re.split () function can be used for more sophisticated pattern-based splitting in situations when the conventional split () …
How to Split Strings in Python: 9 Essential Methods …
Aug 25, 2025 · Python provides multiple ways to break strings into tokens, from the basic str.split() to advanced regular expression splitting with …
Python - Split String - 3 Examples
Python Split String To split a String in Python using delimiter, you can use string split () method. split () method splits the given string by a specified separator, into a list of values. In this …
Python split () Function: Syntax, and Usage Guide
Jul 31, 2025 · Whenever you need to break bigger strings or a line into several small strings, you need to use the split () function in Python. The …