Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 115 - 2615_KEC
P. 115

    lower(): The lower()  method  returns a copy  of the  string  with all characters  converted  to
                       lowercase.
                       Syntax:

                       string_name.lower()
                        upper(): The upper() method returns a copy of the string with all characters converted to
                       uppercase.
                       Syntax:

                       string_name.upper()
                        capitalize(): The capitalize() method returns a string with the first character capitalized and
                       the rest in lowercase.
                       Syntax:

                       string_name.capitalize()
                        title(): The title() method returns a string with the first letter of each word capitalized.
                       Syntax:

                       string_name.title()
                        swapcase(): The swapcase() method returns a string with uppercase characters converted to
                       lowercase and vice versa.
                       Syntax:

                       string_name.swapcase()
                        casefold(): The casefold() method returns a case-insensitive version of the string for comparison
                       purposes.
                       Syntax:
                       string_name.casefold()
                        find(sub): The find() method returns the lowest index where the substring sub is found in the
                       string, or -1 if it is not found.
                       Syntax:
                       string_name.find(sub)
                        replace(old, new): The replace() method returns a new string where all occurrences of the
                       substring old are replaced with new.
                       Syntax:
                       string_name.replace(old, new)
                        split(sep):  The split()  method  splits  the  string  into  a  list  of  substrings  using  the  specified
                       separator sep.
                       Syntax:
                       string_name.split(sep)
                        join(iterable): The join() method concatenates an iterable of strings into a single string, using
                       the original string as a separator.
                       Syntax:
                       string_name.join(iterable)
                        strip(): The strip() method returns a copy of the string with leading and trailing whitespace
                       removed.
                       Syntax:
                       string_name.strip()

                                                                                       Functions, String and List in Python  113

| 110 111 112 113 114 115 116 117 118 119 120 |