About 1,550,000 results
Open links in new tab
  1. 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!

    Using 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!

    Limiting 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!

    Note: The split() method is very useful for parsing and extracting data from strings.

    Feedback
  2. 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 …

  3. 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....
    See more on note.nkmk.me
  4. 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 …

  5. 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 …

  6. 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 …

  7. People also ask
  8. 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 () …

  9. 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 …

  10. 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 …

  11. 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 …