Page 7 - Lesson Note - STRINGS
P. 7

Lesson Note

               count()















               startswith/endswith()
                 Function      string.startswith(<sub>)
                               string.endswith(<sub>)
                 Remarks       Returns True if the function starts with/ ends with the
                               substring sub else returns False

                 Code          >>> 'abcdefgh'.startswith('gh')
                               False
                               >>> 'abcdefgh'.endswith('gh')
                               True

               join()
                   <str>.join(<string iterable>)
                   #joins str after every character of string







               replace()
                   <str>.replace(<word to be replaced>, <replace word>)
                   #replaces every occurrence of first parameter with second parameter in the string







               partition()
               splits the string at the first occurrence of the separator and returns a tuple containing three items
               First → part before separator
               Second → separator
               Third → part after separator
               Syntax:
                         string.partition(<separator/string>)
   2   3   4   5   6   7