Table of Contents
Python basic String pre-defined function
In this tutorial, we will discuss the basic String pre-defined function.
Python language has several pre-defined or built-in string function for string data type
1. str.lower() – This function is used to convert from upper case letter to lower case letter.
2. str.upper() – This function is used to convert from lower case letter to upper case letter.
3. str.join() – This function is used to concatenate two or more string in python.
This function is used to join the white spaces in this string
this function used to join “,” set of this string
4. str.split() – This function is used to split two or more string in python
5. len() – This function is used for the length of the given string in python
Output
35
6. index() This function is used to find the index of given string
Output
4
(‘index of given string’, 4)
7. count() This function is used to count given string
2
(‘count “s” given string’, 2)
8. slice function is used to slice the given range of string
slice
(‘slice string’, ‘ str’)
9. reverse function is used to reverse given string
output
(‘reverse string’, ‘gnirts esrever’)
10. capitalize function is used to capitalalise the first letter of the given string
Output
This is capitalized function
11. Find function is used to find part of the string from the given string
Output
8
12. islower() function is used to find the lower caseof all of the string from the given string
13. islower() function is used to find the upper case of all of the string from the given string
14. replace() function is used to replace one string with another
15. strip() function returns a string with all spaces removed from start till end