GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — Python split() Method - GeeksforGeeks Python split() MethodLast Updated : 1 Jul, 2026 split() method is used to divide a string into multiple parts based on a specified separator. It returns the resulting parts as a list of strings.
Output ['one', 'two', 'three'] Explanation: s.split(',') splits the string s at every comma and returns a list of the parts ['one', 'two', 'three']. Syntax
Parameters:
Return Value: Returns a list of strings containing the parts obtained after splitting the original string. Splitting Strings with Multiple SpacesWhen no separator is specified, consecutive whitespace characters are treated as a single separator.
Output ['Hello', 'world'] Explanation: string contains multiple spaces between "Hello" and "world" and split() automatically treats consecutive spaces as a single separator. Splitting with Different SeparatorsBy default, split() uses whitespace as the separator. However, you can provide any character or string as a delimiter to split the text based on your specific requirements.
Output ['geeks', 'for', 'geeks'] ['geeks', 'for', 'geeks'] ['geeks', 'for', 'geeks'] ['Ca', 'Ba', 'Sa', 'Fa', 'Or'] Explanation:
Using maxsplitThe maxsplit parameter limits the number of splits performed on a string. Once the specified number of splits is reached, the remaining part of the string is returned as a single element.
Output ['apple, banana, mango, orange'] ['apple', 'banana', 'mango', 'orange'] ['apple', 'banana, mango, orange'] Explanation:
Parsing a Sentence into WordsMost common uses of split() is breaking a sentence into individual words. This is useful in text processing, word counting and natural language processing tasks.
Output ['Welcome', 'to', 'Python', 'programming.'] Related Articles:Comment Explore |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |