Post

PythonPython

J
James ROBERT

Posted on 28th February 2024|22 views

0
votes

Split And Strip Python

Explain about split and strip in python?

Answers
P
Lakshmi sowjanya

Posted on 28th February 2024

Split:

This split function will split the string from the positions wherever the provided pattern occurs and returns a list of strings like this:

mystr = “welcomebtobthisbpage”

pattern = “b” 

mystr = mystr.split(pattern)

Output:

mystr 

[‘welcome', 'to', 'this', 'page']

Strip:

This function will remove the provided inputs from both the ends of the given string that is from staring and ending position the string like this:

mystr = "bheyb"

mystr = mystr.strip("b")

Output:

mystr

'hey'

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos