Professional Documents
Culture Documents
=====================
Note:
~~~~~~~~~~
In the given string the duplicate character(s) are existed then it will
return first occurrence of the substring index position will be return.
>>> str="*************Welcome***************"
>>> print(str)
*************Welcome***************
>>> print(str.lstrip('*'))
Welcome***************
>>>
>>>
>>>
>>> print(str.lstrip("Welcome"))
*************Welcome***************
>>>
>>>
>>> str="Welcome************Welcome***********Welcome"
>>> print(str.lstrip("Welcome")
)
************Welcome***********Welcome
>>>
>>>
>>>
>>> str="------------Hello World-------------"
>>> print(str.rstrip('-'))
------------Hello World
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> str=" Computer Programming "
>>> print(str)
Computer Programming
>>>
>>>
>>> print(str.lstrip())
Computer Programming
>>>
>>>
>>>
>>>
>>> print(str.rstrip())
Computer Programming
>>>
>>>
>>>
>>>
>>> str="$$$$$$$$$$$$$$$$$Welcome$$$$$$$$$$$$$$$$$$$$"
>>>
>>>
>>>
>>> print(str)
$$$$$$$$$$$$$$$$$Welcome$$$$$$$$$$$$$$$$$$$$
>>>
>>>
>>>
>>> print(str.lstrip('$'))
Welcome$$$$$$$$$$$$$$$$$$$$
>>>
>>>
>>> print(str.rstrip('$'))
$$$$$$$$$$$$$$$$$Welcome
>>>
>>> print(str.strip('$'))
Welcome
>>>
>>>
>>>
>>>
>>> str=" Hi "
>>>
>>>
>>>
>>> print(str)
Hi
>>>
>>>
>>> print(str.lstrip())
Hi
>>>
>>>
>>>
>>>
>>> print(str.rstrip())
Hi
>>>
>>>
>>>
>>>
>>> print(str.strip())
Hi
>>> sep='-'
>>> str=("Python","Programming","By Experts")
>>> type(str)
<class 'tuple'>
>>>
>>>
>>>
>>> print(sep.join(str))
Python-Programming-By Experts
>>>
>>>
Output
~~~~~~~~~~~