Difference Between strip and split in Python Last Updated : 13 Nov, 2024 Comments Improve Suggest changes Like Article Like Report The major difference between strip and split method is that strip method removes specified characters from both ends of a string. By default it removes whitespace and returns a single modified string. Whereas, split method divides a string into parts based on a specified delimiter and by default it splits by whitespace and returns a list of strings.Example of strip() Python s = " hello world " # Removes spaces from both ends print(s.strip()) s1 = "***hello***" # Removes asterisks from both ends print(s1.strip("*")) Outputhello world hello Explanation: s.strip() removes spaces from both beginning and end of the string and results in "hello world".strip("*") removes * characters from both ends and results in "hello".Example of split() Python s = "hello world" # Splits by whitespace print(s.split()) s1 = "apple,orange,banana" # Splits by comma print(s1.split(',')) Output['hello', 'world'] ['apple', 'orange', 'banana'] Explanation: s.split() basically splits "hello world" into two elements based on whitespace and results in ['hello', 'world']split(',') divides string at each comma and results in list ['apple', 'orange', 'banana'] Comment More infoAdvertise with us Next Article Difference Between strip and split in Python C chinmoy lenka Follow Improve Article Tags : Python Python-Built-in-functions python-string Practice Tags : python Similar Reads Difference between end and sep in Python In this article we will discuss the difference between The end and sep are two parameters in Python's built-in print() function that will help to control how the output is formatted. end in PythonThe end is a parameter in Python's built-in print() function that controls what character(s) are printed 2 min read Difference between / vs. // operator in Python In Python, both / and // are used for division, but they behave quite differently. Let's dive into what they do and how they differ with simple examples./ Operator (True Division)The / operator performs true division.It always returns a floating-point number (even if the result is a whole number).It 2 min read Difference Between Del, Remove and Pop in Python Lists del is a keyword and remove(), and pop() are in-built methods in Python. The purpose of these three is the same but the behavior is different. remove() method deletes values or objects from the list using value and del and pop() deletes values or objects from the list using an index.del Statementdel 2 min read Split and Parse a string in Python In this article, we'll look at different ways to split and parse strings in Python. Let's understand this with the help of a basic example:Pythons = "geeks,for,geeks" # Split the string by commas res = s.split(',') # Parse the list and print each element for item in res: print(item)Outputgeeks for g 2 min read How to Index and Slice Strings in Python? In Python, indexing and slicing are techniques used to access specific characters or parts of a string. Indexing means referring to an element of an iterable by its position whereas slicing is a feature that enables accessing parts of the sequence.Table of ContentIndexing Strings in PythonAccessing 2 min read Like