Categories: Python

Python basic String pre-defined function

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.

 

str.lower() function
2. str.upper() – This function is used to convert from lower case letter to upper case letter.
str.upper() function
    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
str.jion() function

                    this function used to join “,” set of this string
    4. str.split() – This function is used to split two or more string in python
str.split() function
     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
str.strp() function
Karmehavannan

Share
Published by
Karmehavannan

Recent Posts

Using function or method to Write temperature conversion : Fahrenheit into Celsius

Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…

11 months ago

Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user

Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…

11 months ago

Write temperature conversion program: Fahrenheit into Celsius

Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…

11 months ago

How to write a program to convert Fahrenheit into Celsius

How to write a program to convert Fahrenheit into Celsius In this article, we will…

11 months ago

Function/method to convert Celsius into Fahrenheit -Entered by user

Function/method to convert Celsius into Fahrenheit -Entered by user In this article, we will discuss…

12 months ago

Temperature conversion: Celsius into Fahrenheit using function or method

Temperature conversion: Celsius into Fahrenheit using a function or method In this article, we will…

12 months ago

This website uses cookies.