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

Recent Posts

Multiply two numbers in Java using scanner| 5 different ways

Multiply two numbers in Java using scanner| 5 different ways In this article, we will…

3 months ago

5 different ways to Divide two numbers in Java using scanner

5 Different ways to Divide two numbers in Java using scanner In this article, we…

3 months ago

Learn 8 Ways to Subtract Two Numbers Using Methods in Java

Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…

4 months ago

10 ways to subtract two numbers in Java

10 ways to subtract two numbers in Java In this article, we will discuss the…

4 months ago

Java Code Examples – Multiply Two Numbers in 5 Easy Ways

Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…

4 months ago

How to Divide two numbers in Java| 5 different ways

How to Divide two numbers in Java| 5 different ways In this article, we will…

4 months ago

This website uses cookies.