built-in function to support the string operation which can be very useful to know if you're getting you hand on any programming challenge. Today we will discuss about
strip and Split methods.
char would be the character to be removed from the given string. It would return a copy of the given string,
char removed from the beginning and end of the string.
if no argument is given, then it will strip the
white-space from the beginning or end of the string.
input_string="pppppLevel-up your python with http://LearningWithPython.comppppp" input_string.strip('p')
'Level-up your python with http://LearningWithPython.com'
str would be the string by which the main string to be separated. It will return the list with the all word separated by the given
Let's separate it based on ','
['Level up', 'your', 'python', 'with', 'http://LearningWithPython.com']
Take another example:
input_str1="Level up your python with http://LearningWithPython.com"
Now separate it based on 'space'.
['Level', 'up', 'your', 'python', 'with', 'http://LearningWithPython.com']
Usage:- To break down the large string into smaller one or opposite on string concatenation.Published On : 2017-03-08 Tweet