Sitemap
Sehwagbaipalli

Sehwagbaipalli

String Methods

5 min readNov 16, 2026

String methods are predefined or inbuilt functions available for perform different types of operations on strings in python.

String is collection or sequence of characters which is written in between single, double and triple quotes( ‘ ’ , “ ” , “‘ ’” ) .

Syntax of string methods :

string.method()

string methods are used to convert the cases of letters, remove unwanted spaces, replace the existing text, split a string etc,.

Get Sehwagbaipalli’s stories in your inbox

Join Medium for free to get updates from this writer.

Types of String methods :

  1. lower() : It converts all uppercase letters in a string into lowercase letter and ignore the other. syntax is string.lower()

2. upper() : It converts all lower case letters into uppercase letters and ignore the remaining. syntax is string.upper()

3. swapcase() : it converts uppercase into lower case and lower case into uppercase. syntax is string.swapcase()

4. capitalize() : it converts first character into uppercase and remaining characters into lowercase. syntax is string.capitalize()

5. title() : it converts the first character of each word into uppercase and remaining into lowercase. syntax is string.title()

6. count() : it is used to count the particular character or substring present in a string. syntax is string.count()

7. index() : it is used to find the index position of particular character or first occurence of substring in a string. if it is not find the position it returns an error. syntax is string.index()

8. find() : it is used to find the index position of particular character or first occurence of substring in a string. if it is not find it returns -1. syntax is string.find().

9. strip() : it is used to remove unwanted spaces and unwanted characters from the begining and ending of the string. syntax is string.strip()

10. lstrip() : It is used to remove the unwanted spaces and characters from the left side. synatx is string.lstrip()

11. rstrip() : It is used to remove the unwanted spaces and characters from the left side. synatx is string.rstrip()

12. split() : It is used to divide a string into smaller substrings. used to separate the sentence, names and data. syntax is string.split()

13. rsplit() : It is used to divide a string into smaller substrings from the right side. used to separate the sentence, names and data. syntax is string.rsplit()

14. replace() : It is used to replace an existing substring or character with another character or substring. syntax is string.replace(old,new)

15. rfind() : It is used to search the position of the character or substring from the right side.it not present it shows the -1. syntax is string.rfind()

16. rindex() : It is used to search the position of the character or substring from the right side.it not present it raises an error. syntax is string.rindex()

Press enter or click to view image in full size

17. isupper() : It is used to check the all characters in a string is uppercased or not. it returns true or false. syntax is string.isupper()

18. islower() : It is used to check the all characters in a string is lowercased or not. it returns true or false. syntax is string.islower()

19. istitle() : It is used to check the first character of a words in string is uppercased or not. it returns true or false. syntax is string.istitle()

20. isdigit() : It is used to check whether all the characters are numbers or not in a string. If it is numbers only present in a string it returns true otherwise it returns false. syntax is string.isdigit()

21. isalpha() : It is used to check whether all the characters are alphabets or not in a string. If it is alphabets only present in a string it returns true otherwise it returns false. syntax is string.isalpha()

Press enter or click to view image in full size

22. isalnum() : It is used to check whether all the characters are numbers and alphabetic letters or not in a string. If it is letters and numbers present in a string it returns true otherwise it returns false. syntax is string.isalnum()

Press enter or click to view image in full size

--

--