Other methods are discussed in this article
1. len () : — This function returns the length of the string.
2. count ("string", beg, end) : — this function counts occurrences of the specified substring in the entire string. This function takes 3 arguments: ubstring, start position (default 0) and end position (default line length).
The length of string is: 26 Number of appearance of geeks is: 2
3. center () : — This function is used to surround a string with a character repeated on both sides of the string several times. By default, the character is a space. Takes 2 arguments, string length and character.
4. ljust () : — This function returns the original string shifted to the left , with a character to the right . He corrects the line on the left. By default, the character is a space. It also takes two arguments: string length and character.
5. rjust () : — This function returns a right-shifted original string with a character to the left . This adjusts the line correctly. By default, the character is a space. It also takes two arguments: line length and character.
The string after centering with ’-’ is: --- pythonengineering ---- The string after ljust is: pythonengineering ------- The string after rjust is: ------- pythonengineering
6. isalpha () : — This function returns true when all characters in the string are alphabets, otherwise it returns false.
7. isalnum () : — this function returns true if all characters in the string are combinations of numbers and / or alphabets; otherwise it returns false.
8. isspace () : — This function returns true when all characters in the string are spaces, otherwise it returns false.
All characters are alphabets in str All characters are numbers in str1 All characters are not spaces in str1
9. join () : — This function is used to concatenate a sequence of lines mentioned in its arguments with a string.
The string after joining is: geeks_for_geeks
This article is contributing to Manjeet Singh If you love Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting the article [email protected] See my article appearing on the Python.Engineering homepage and help other geeks.
Please post comments if you find anything wrong or if you would like to share more information on the topic discussed above.