Python String Functions

Python String Functions

  • Python has a set of built-in methods that you can use on strings. 

  • Python has many very useful string methods.

Method                 Description

Find( )                                          Return index of occurrence of given data

rfind( )                                          Rfind reverse find

Index( )                                         Returns Index of Sub string

rindex( )                                        Rindex means reverse index

Startswith( )                                  Checks if String Starts with the Specified String

Endswith( )                                   Checks if String Ends with the Specified Suffix

isalpha( )                                       Checks if All Characters are Alphabets

isspace( )                                       Checks White space Characters

isalum( )                                        Checks Alphanumeric Character 

islower( )                                       Checks if all Alphabets in a String are Lowercase

isupper( )                                       Returns if all characters are uppercase characters

istitle( )                                          Checks for Title cased String 

isdigit( )                                        Checks Digit Characters 

strip( )                                           Removes Both Leading and Trailing Characters

lstrip( )                                          Removes Leading Characters

rstrip( )                                          Removes Trailing Characters

min( )                                            Returns the smallest value

max( )                                           Returns the largest item

swapcase( )                                  Swap uppercase characters to lowercase & vice-versa

split( )                                          Splits String from Left 

upper( )                                        Returns uppercase string

lower( )                                        Returns lowercase string

title( )                                           Returns a Title Cased String

len( )                                            Returns Length of an Object

count( )                                        Returns occurrences of sub string in string

replace( )                                     Replaces Sub string Inside

join( )                                          Returns a Concatenated String

capitalize( )                                 Converts first character to Capital Letter

casefold( )                                   Converts to case folded strings