“Let’s learn Different Built-in Functions for String Data Type”-Part III

Sandeshgaikwad
4 min readSep 21, 2023

--

Hello everyone sandesh here again with the next part of the article.
In previous two articles we seen few built in functions for the string data type.
https://medium.com/@sandeshgaikwad14/lets-learn-different-built-in-functions-for-string-data-type-part-ii-2deeac85a45a

Let’s start our today's article.In today’s article we will read information about more few built in functions.

'join', 'ljust', 'lower', 'lstrip', 'partition', 'removeprefix', 'removesuffix', 'replace', 'rfind', 'rindex', 'rjust', 'rstrip','strip'

str.join method

By using this method we can add new characters or any special characters after ever single characters which are presents in the provided strings.and by using this we can type each characters one below one.The string whose method is called is inserted in between each given string.The result is returned as a new string.

str.ljust and rjust method

we cannot use variable in the parameter it will print variable as it is instead of its assign value
we can use only single character or special character in parameter
when we give any value in parameter as 10 or 20 or something,always make sure that value should be more than the count of the all the characters present in string means if 10 characters in string the value should be 11 or more.

str.lower method

it will converts all the uppercase to lowercase
this method is not applicable for numeric and special characters because,we cant defined them as upper or lower.

str.partition method

By using this function.if it found separator then it returns 3-tuple first before separator ,second itself separator,and third after separator.
It always gives only 3 tuple no matter how long your string is.
If your string has a specific word that repeat multiple times and you put that word as separator it always consider first occurrence.
And if separator is not found means we put such a word is not present in the strings even so it will returns 3 tuple first is full string and other two are empty strings

str.lstrip and rstrip method

By using lstrip function we can completely strip the right side width of the string and value shift to the extreme left.by using rstrip function we can strip both sides width of the string.

str.removeprefix an removesuffix

By using this we can remove beginnings or endings single or multiple characters.
Beginnings characters are prefix and endings characters are suffix.If not right prefix or suffix found it returns full string as it is.

str.replace

By using this this method we can replace old word with the new word.
If word is not in the string it returns string as it is
It allows maximum 3 arguments otherwise error occurs.
If we want to replace occurrences needs to provide valid count

str.rfind

We will get highest index by using this method,in .index method we get first occurred index.We can find subsrtings index by giving start and end index
If there is wrong input it will returns -1
Return the highest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.

Return -1 on failure.

str.rfind

By using this we will get highest index,and by using .find will get frist occurred index.Return the highest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

I hope you all find this information,will meet with new article with remaining functions.
Thanks!

#vevcodelab
@sandeshgaikwad

--

--